diff options
author | 2024-01-31 16:28:23 +0100 | |
---|---|---|
committer | 2024-01-31 23:28:23 +0800 | |
commit | 7be5f94dcfc73a78d0fb301eeff51614d987a165 (patch) | |
tree | b41983cd318a508fb509662754e324f2caa81f14 | |
parent | 38e40f1cc245d8a755e8b498632bab49680db0a4 (diff) | |
download | astro-7be5f94dcfc73a78d0fb301eeff51614d987a165.tar.gz astro-7be5f94dcfc73a78d0fb301eeff51614d987a165.tar.zst astro-7be5f94dcfc73a78d0fb301eeff51614d987a165.zip |
fix: content types reference to config on windows (#9877)
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
-rw-r--r-- | .changeset/funny-mice-help.md | 5 | ||||
-rw-r--r-- | packages/astro/src/content/types-generator.ts | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/.changeset/funny-mice-help.md b/.changeset/funny-mice-help.md new file mode 100644 index 000000000..9cedc017c --- /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 d08f15109..62f2fffbd 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({ |