0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-03-31 23:31:30 -05:00

fix(astro): terminal HMR path (close #8831) (#8863)

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
This commit is contained in:
Florian Lefebvre 2023-10-20 12:01:54 +02:00 committed by GitHub
parent 5c888c10b7
commit 326e178933
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fixes an issue where the dev server logged the full file path on updates.

View file

@ -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) {