vanilla-extract missing CSS with HTML-only rendering (in dev only)
See original GitHub issueDescription
Hey, first I wanted to thank you for all your work, i’m very glad to see how far VPS has got and also excited to see where it’s going (especially the single file RFC 👀 ) !
Context:
- vanilla-extract is a CSS-in-JS lib with mostly no runtime, except when using the
sprinkles
package - i’m trying to use VPS with HTML-only pages (.page.server) since it would be a nice match (0 runtime CSS from VE + 0 runtime JS from VPS), but then found that styles are missing after visiting a page that has client-side JS sent (.page.client) in dev only, it works fine when using
vite build
+vite preview
- maybe related to https://github.com/brillout/vite-plugin-ssr/issues/411
it (VE in SSR in dev) works fine with other frameworks (rakkas/qwik/next, havent tried others) or others rendering modes of VPS, which makes me think this might be a VPS problem i’ve been digging a lot today and couldn’t find a way to fix this in the VE-plugin, i’m no expert in making vite plugin so it might also just be me not being good enough in that field
Steps to reproduce
- pnpm i
- pnpm dev
- visit localhost:3000
- go to
zero-js
page, see there the CSS is there, everything is ok (even tho this line was forced to true, was needed in the VE plugin, without it there was no CSS at all for the HTML-only page…) - you can visit any page that has no client-side js (=you can’t visit “with-js” page) and the CSS will still be fine
- then visit the
with-js
page, everything is still fine - go back to
zero-js
page, the CSS for that page is gone and won’t ever come back unless completely stop+restarting the vite dev server
this is what happens :
Workaround
I have found a workaround, with this the CSS will not be missing when using HTML-only pages (.page.server
+ ssr({ includeAssetsImportedByServer: true})
)
this is what happens when I use a .page.client & dynamic import the sprinkles manually in dev mode only, what expected would happen :
please tell me if there’s anything I can do to help !
Error Message + Error Stack
No response
Issue Analytics
- State:
- Created 9 months ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
I see, looking forward to it. (FYI we may not even need that with https://github.com/vitejs/vite/pull/11430. But it may take a while until the PR is merged, so let’s go for your proposed fix in the meantime.)
This really seems more like a VE thing than a VPS thing. So let’s close this.
Let me know if you believe there is anything VPS can do here.
Btw. in case your company would be up for it: https://github.com/sponsors/brillout.