How to build static css stylesheet from css-in-js in SvelteKit?

Viewed 309

I have written my own CSS-in-JS library for performance benefit, and I want to use it with Svelte as well. It works in Svelte, but I am struggling how to generate the rules as static CSS stylesheet and serve it in the HTML.

Back in React days, I used to have a script in bundler (rollup/snowpack) that calls <App /> in buildtime. After it is ran, all my css-in-js functions will be called, and I can get all processed rules in the cache, then I can inject those cached rules.

But as svelte is compiled, this method doesn't work. I don't have a single entrypoint to do this trick. Is it possible do this in svelte? It doesn't matter if the styles are injected in the html, or as a standalone css stylesheet.

0 Answers
Related