From 3e4cfea4e29ab958d69e4502c1f634a007393a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikkel=20T=C3=B8nder?= <71938724+Mikkel-T@users.noreply.github.com> Date: Fri, 3 Dec 2021 16:53:11 +0100 Subject: [PATCH] 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 --- .changeset/chilled-coins-wash.md | 5 +++++ packages/astro/src/vite-plugin-config-alias/index.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/chilled-coins-wash.md 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[] = [];