summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Nate Moore <natemoo-re@users.noreply.github.com> 2023-11-29 09:12:43 -0600
committerGravatar GitHub <noreply@github.com> 2023-11-29 09:12:43 -0600
commit067a65f5b4d163bf1944cf47e6bf891f0b93553f (patch)
tree40888856c2d6d211d07fcaa646d0bae76c47141d
parent1e8d28de7f47e816cb95851025df48998f52a996 (diff)
downloadastro-067a65f5b4d163bf1944cf47e6bf891f0b93553f.tar.gz
astro-067a65f5b4d163bf1944cf47e6bf891f0b93553f.tar.zst
astro-067a65f5b4d163bf1944cf47e6bf891f0b93553f.zip
fix(#9216): fix style HMR in certain cases (#9219)
-rw-r--r--.changeset/wicked-books-appear.md5
-rw-r--r--packages/astro/src/vite-plugin-astro/hmr.ts4
2 files changed, 7 insertions, 2 deletions
diff --git a/.changeset/wicked-books-appear.md b/.changeset/wicked-books-appear.md
new file mode 100644
index 000000000..930091da7
--- /dev/null
+++ b/.changeset/wicked-books-appear.md
@@ -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.
diff --git a/packages/astro/src/vite-plugin-astro/hmr.ts b/packages/astro/src/vite-plugin-astro/hmr.ts
index 27cc2d10f..ca1c13a95 100644
--- a/packages/astro/src/vite-plugin-astro/hmr.ts
+++ b/packages/astro/src/vite-plugin-astro/hmr.ts
@@ -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