From a0f4f38bbaad19786dfbe3fe5c180709822804a7 Mon Sep 17 00:00:00 2001 From: Nikhil Saraf Date: Wed, 27 Dec 2023 18:56:06 +0530 Subject: [PATCH 1/2] (fix): css hmr happens in vinxi/client for all css assets, not only for lazyRoutes --- packages/vinxi/runtime/client.js | 10 ++++++++++ packages/vinxi/runtime/style.js | 12 +++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/vinxi/runtime/client.js b/packages/vinxi/runtime/client.js index 134e044f..4c031cbb 100644 --- a/packages/vinxi/runtime/client.js +++ b/packages/vinxi/runtime/client.js @@ -7,4 +7,14 @@ if (import.meta.env.DEVTOOLS && import.meta.env.DEV) { }; } +if (typeof window !== "undefined" && import.meta.hot) { + import.meta.hot.on("css-update", (data) => { + for (const el of document.querySelectorAll( + `style[data-vite-dev-id="${data.file}"]`, + )) { + el.innerHTML = data.contents; + } + }); +} + globalThis.MANIFEST = manifest; diff --git a/packages/vinxi/runtime/style.js b/packages/vinxi/runtime/style.js index 3f69778d..002cf850 100644 --- a/packages/vinxi/runtime/style.js +++ b/packages/vinxi/runtime/style.js @@ -1,7 +1,7 @@ /** - * - * @param {*} styles - * @param {*} data + * + * @param {*} styles + * @param {*} data */ export function updateStyles(styles, data) { let styleAsset = styles.find( @@ -10,12 +10,6 @@ export function updateStyles(styles, data) { if (styleAsset) { styleAsset.children = data.contents; } - - for (const el of document.querySelectorAll( - `style[data-vite-dev-id="${data.file}"]`, - )) { - el.innerHTML = data.contents; - } } export function appendStyles(styles) { From a0974f037aac6a445fd37d03413f557f2e21b21a Mon Sep 17 00:00:00 2001 From: Nikhil Saraf Date: Wed, 27 Dec 2023 19:13:42 +0530 Subject: [PATCH 2/2] Create fresh-peas-protect.md --- .changeset/fresh-peas-protect.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/fresh-peas-protect.md diff --git a/.changeset/fresh-peas-protect.md b/.changeset/fresh-peas-protect.md new file mode 100644 index 00000000..c263d4bf --- /dev/null +++ b/.changeset/fresh-peas-protect.md @@ -0,0 +1,6 @@ +--- +"vinxi": patch +"solid-spa-basic": patch +--- + +(fix): css hmr happens in vinxi/client for all css assets, not only for lazyRoutes