Skip to content

Commit

Permalink
fix(#9216): fix style HMR in certain cases (#9219)
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re authored Nov 29, 2023
1 parent 1e8d28d commit 067a65f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/wicked-books-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix edge case where `<style>` updates inside of `.astro` files would ocassionally fail to update without reloading the page.
4 changes: 2 additions & 2 deletions packages/astro/src/vite-plugin-astro/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export async function handleHotUpdate(
// If only styles are changed, remove the component file from the update list
if (isStyleOnlyChange) {
logger.info('astro', msg.hmr({ file, style: true }));
// remove base file and hoisted scripts
return mods.filter((mod) => mod.id !== ctx.file && !mod.id?.endsWith('.ts'));
// Only return the Astro styles that have changed!
return mods.filter((mod) => mod.id?.includes('astro&type=style'));
}

// Add hoisted scripts so these get invalidated
Expand Down

0 comments on commit 067a65f

Please sign in to comment.