From 7be5f94dcfc73a78d0fb301eeff51614d987a165 Mon Sep 17 00:00:00 2001 From: Fabian Kachlock Date: Wed, 31 Jan 2024 16:28:23 +0100 Subject: [PATCH] fix: content types reference to config on windows (#9877) Co-authored-by: Florian Lefebvre --- .changeset/funny-mice-help.md | 5 +++++ packages/astro/src/content/types-generator.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/funny-mice-help.md diff --git a/.changeset/funny-mice-help.md b/.changeset/funny-mice-help.md new file mode 100644 index 0000000000..9cedc017cb --- /dev/null +++ b/.changeset/funny-mice-help.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Fixes the content config type path on windows diff --git a/packages/astro/src/content/types-generator.ts b/packages/astro/src/content/types-generator.ts index d08f151092..62f2fffbd6 100644 --- a/packages/astro/src/content/types-generator.ts +++ b/packages/astro/src/content/types-generator.ts @@ -345,8 +345,10 @@ function invalidateVirtualMod(viteServer: ViteDevServer) { */ function normalizeConfigPath(from: string, to: string) { const configPath = path.relative(from, to).replace(/\.ts$/, '.js'); + // on windows `path.relative` will use backslashes, these must be replaced with forward slashes + const normalizedPath = configPath.replaceAll('\\', '/'); - return `"${isRelativePath(configPath) ? '' : './'}${configPath}"` as const; + return `"${isRelativePath(configPath) ? '' : './'}${normalizedPath}"` as const; } async function writeContentFiles({