Skip to content

Commit c892d24

Browse files
committed
fix(style-dev): style css for dev with vite js module
This will fix the missing styles with vite 6 for dai-shi#1012 It works by running js from the browser to create the styles with CSR in dev. Before we were extracting the source for plain css and passing those from the dev server in a <style> tag, but since that breaks in vite 6, this is an easy solution that will handle styles more consistently and without errors.
1 parent 86b805a commit c892d24

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

packages/waku/src/lib/plugins/vite-plugin-rsc-hmr.ts

+11-22
Original file line numberDiff line numberDiff line change
@@ -225,28 +225,17 @@ async function generateInitialScripts(
225225
const scripts: HtmlTagDescriptor[] = [];
226226

227227
for (const result of sources.values()) {
228-
if (result.id.endsWith('.module.css')) {
229-
// CSS modules do not support result.source (empty) since ssr-transforming them gives the css keys and client-transforming them gives the script tag for injecting them.
230-
// Since we use the client-transformed script tag, we need to avoid FOUC by blocking render
231-
scripts.push({
232-
tag: 'script',
233-
attrs: {
234-
type: 'module',
235-
async: true,
236-
blocking: 'render',
237-
'waku-module-id': result.id,
238-
},
239-
children: result.code,
240-
injectTo: 'head',
241-
});
242-
} else {
243-
scripts.push({
244-
tag: 'style',
245-
attrs: { type: 'text/css', 'waku-module-id': result.id },
246-
children: result.source,
247-
injectTo: 'head',
248-
});
249-
}
228+
scripts.push({
229+
tag: 'script',
230+
attrs: {
231+
type: 'module',
232+
async: true,
233+
blocking: 'render',
234+
'waku-module-id': result.id,
235+
},
236+
children: result.code,
237+
injectTo: 'head',
238+
});
250239
}
251240
return scripts;
252241
}

0 commit comments

Comments
 (0)