From 326e178933f7a22f4e897b763832619f168b53dd Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Fri, 20 Oct 2023 12:01:54 +0200 Subject: [PATCH] fix(astro): terminal HMR path (close #8831) (#8863) Co-authored-by: Sarah Rainsberger --- .changeset/two-lamps-tell.md | 5 +++++ packages/astro/src/vite-plugin-astro/hmr.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/two-lamps-tell.md diff --git a/.changeset/two-lamps-tell.md b/.changeset/two-lamps-tell.md new file mode 100644 index 000000000000..c79d1764b3ce --- /dev/null +++ b/.changeset/two-lamps-tell.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes an issue where the dev server logged the full file path on updates. diff --git a/packages/astro/src/vite-plugin-astro/hmr.ts b/packages/astro/src/vite-plugin-astro/hmr.ts index 6600b2f42271..27cc2d10fca8 100644 --- a/packages/astro/src/vite-plugin-astro/hmr.ts +++ b/packages/astro/src/vite-plugin-astro/hmr.ts @@ -1,3 +1,4 @@ +import { slash } from '@astrojs/internal-helpers/path'; import { fileURLToPath } from 'node:url'; import type { HmrContext, ModuleNode } from 'vite'; import type { AstroConfig } from '../@types/astro.js'; @@ -91,7 +92,7 @@ export async function handleHotUpdate( // Bugfix: sometimes style URLs get normalized and end with `lang.css=` // These will cause full reloads, so filter them out here const mods = [...filtered].filter((m) => !m.url.endsWith('=')); - const file = ctx.file.replace(config.root.pathname, '/'); + const file = ctx.file.replace(slash(fileURLToPath(config.root)), '/'); // If only styles are changed, remove the component file from the update list if (isStyleOnlyChange) {