summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Mikkel Tønder <71938724+Mikkel-T@users.noreply.github.com> 2021-12-03 16:53:11 +0100
committerGravatar GitHub <noreply@github.com> 2021-12-03 10:53:11 -0500
commit3e4cfea4e29ab958d69e4502c1f634a007393a7b (patch)
tree21182ffb7f9b92b136b5041fd010b57e1f8452ef
parent213a2622e2d126328e5752716f659937896cc88a (diff)
downloadastro-3e4cfea4e29ab958d69e4502c1f634a007393a7b.tar.gz
astro-3e4cfea4e29ab958d69e4502c1f634a007393a7b.tar.zst
astro-3e4cfea4e29ab958d69e4502c1f634a007393a7b.zip
Make aliases work on windows (#2109)
* Make aliases work on windows Change all occurrences of path.posix to path. * Remove console log statement * Update index.ts * Update index.ts * Update index.ts * Edit changeset
-rw-r--r--.changeset/chilled-coins-wash.md5
-rw-r--r--packages/astro/src/vite-plugin-config-alias/index.ts2
2 files changed, 6 insertions, 1 deletions
diff --git a/.changeset/chilled-coins-wash.md b/.changeset/chilled-coins-wash.md
new file mode 100644
index 000000000..df26f52d1
--- /dev/null
+++ b/.changeset/chilled-coins-wash.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Fixes aliases on windows.
diff --git a/packages/astro/src/vite-plugin-config-alias/index.ts b/packages/astro/src/vite-plugin-config-alias/index.ts
index 7ed003b1b..b1e421187 100644
--- a/packages/astro/src/vite-plugin-config-alias/index.ts
+++ b/packages/astro/src/vite-plugin-config-alias/index.ts
@@ -35,7 +35,7 @@ const getConfigAlias = (cwd: string | undefined): Alias[] | null => {
if (!compilerOptions.baseUrl) return null;
// resolve the base url from the configuration file directory
- const baseUrl = path.posix.resolve(path.posix.dirname(normalize(config.path)), normalize(compilerOptions.baseUrl));
+ const baseUrl = path.posix.resolve(path.posix.dirname(normalize(config.path).replace(/^\/?/, '/')), normalize(compilerOptions.baseUrl));
/** List of compiled alias expressions. */
const aliases: Alias[] = [];