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) {