From 4e55be9006bf4b4dba94171388f6cbb7f5ec63f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Moln=C3=A1r?= <62985992+bencemol@users.noreply.github.com> Date: Mon, 15 Nov 2021 18:47:39 +0100 Subject: [PATCH] Use normalized path to detect layout files (#1822) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bence Molnár --- .changeset/strong-bugs-confess.md | 5 +++++ packages/astro/src/vite-plugin-astro/index.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/strong-bugs-confess.md diff --git a/.changeset/strong-bugs-confess.md b/.changeset/strong-bugs-confess.md new file mode 100644 index 000000000..4436d3f2c --- /dev/null +++ b/.changeset/strong-bugs-confess.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes layout file detection on non-unix environments diff --git a/packages/astro/src/vite-plugin-astro/index.ts b/packages/astro/src/vite-plugin-astro/index.ts index 891c88996..ea321f65b 100644 --- a/packages/astro/src/vite-plugin-astro/index.ts +++ b/packages/astro/src/vite-plugin-astro/index.ts @@ -48,7 +48,7 @@ export default function astro({ config, devServer }: AstroPluginOptions): vite.P // pages and layouts should be transformed as full documents (implicit 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;