question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vanilla-extract missing CSS with HTML-only rendering (in dev only)

See original GitHub issue

Description

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

minimal repro

  • 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 : Kapture 2022-12-07 at 01 04 08

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 : Kapture 2022-12-07 at 01 05 27

please tell me if there’s anything I can do to help !

Error Message + Error Stack

No response

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
brilloutcommented, Dec 21, 2022

i’ll soon open another issue

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

1reaction
brilloutcommented, Dec 8, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Alexandre Stahmer astahmer - GitHub
Frenchy freelance web/Typescript dev . astahmer has 64 repositories available. ... vanilla-extract missing CSS with HTML-only rendering (in dev only).
Read more >
CSS is not being rendered on my page, only the HTML
I am using WP coder for adding custom HTML and CSS content sections numerous times on this page. The HTML content seems to...
Read more >
Writing Performant CSS with vanilla-extract : r/javascript - Reddit
It's no longer just this wierd one off thing. Vanilla extract is becoming popular because styled components has perf issues, and so it...
Read more >
Vanilla Extract - a Modern CSS in JS Library - InfoQ
Vanilla Extract is a new "CSS in JS" library that offers type safety, good theming support, and plenty of extensions, making it an...
Read more >
Theming - Vanilla Extract
For example, a component being rendered in different color schemes. Theming in vanilla-extract is really just a set of helpers on top of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found