Use normalized path to detect layout files (#1822)

Co-authored-by: Bence Molnár <bencemol@users.noreply.github.com>
This commit is contained in:
Bence Molnár 2021-11-15 18:47:39 +01:00 committed by GitHub
parent 3b8f201c4b
commit 4e55be9006
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fixes layout file detection on non-unix environments

View file

@ -48,7 +48,7 @@ export default function astro({ config, devServer }: AstroPluginOptions): vite.P
// pages and layouts should be transformed as full documents (implicit <head> <body> etc)
// everything else is treated as a fragment
const normalizedID = fileURLToPath(new URL(`file://${id}`));
const isPage = normalizedID.startsWith(fileURLToPath(config.pages)) || id.startsWith(fileURLToPath(config.layouts));
const isPage = normalizedID.startsWith(fileURLToPath(config.pages)) || normalizedID.startsWith(fileURLToPath(config.layouts));
let source = await fs.promises.readFile(id, 'utf8');
let tsResult: TransformResult | undefined;