Skip to content

Commit

Permalink
fix(astro): terminal HMR path (close #8831) (#8863)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
  • Loading branch information
florian-lefebvre and sarah11918 committed Oct 20, 2023
1 parent 5c888c1 commit 326e178
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/two-lamps-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes an issue where the dev server logged the full file path on updates.
3 changes: 2 additions & 1 deletion packages/astro/src/vite-plugin-astro/hmr.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 326e178

Please sign in to comment.