Skip to content

Commit

Permalink
(fix): css hmr happens in vinxi/client for all css assets, not only f…
Browse files Browse the repository at this point in the history
…or lazyRoutes
  • Loading branch information
nksaraf committed Dec 27, 2023
1 parent efc56d5 commit a0f4f38
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
10 changes: 10 additions & 0 deletions packages/vinxi/runtime/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
12 changes: 3 additions & 9 deletions packages/vinxi/runtime/style.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
* @param {*} styles
* @param {*} data
*
* @param {*} styles
* @param {*} data
*/
export function updateStyles(styles, data) {
let styleAsset = styles.find(
Expand All @@ -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) {
Expand Down

0 comments on commit a0f4f38

Please sign in to comment.