Stylex styles don't get loaded in preview / production but it works in dev mode #2785
Unanswered
PrivateN00b
asked this question in
Help & Questions
Replies: 1 comment 3 replies
-
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm currently using stylex (it's a CSS-in-JS library where the styles are loaded on build instead on the runtime) and styled-components for my personal vike based webapp, but whilst styled-components's styles are getting loaded without any issues in both dev and production, my stylex only works in dev mode.
The only reason it works in dev mode is because the styles are actually loaded in whilst on the runtime, set by the runtimeInjection parameter in
@stylexjs/babel-plugin.facebook/stylex#1043 (comment)Obviously using
runtimeInjection: truewon't work in production, and the main devs also seem to struggle in creating a decent integration into Vite with some cool stylex vite plugin, but just to preface, using stylex on Vite is actually viable in prod, which I was able to replicate / achieve.I was thinking that one of the last steps in the Vite stylex integration is importing a stylex.css containing a
@stylexdirective which is used by a@stylexjs/postcss-pluginto make stylex style loading possible into Vite's entrypoint which is usually amain.tsxif React is being used. In Vike's case I've imported this into LayoutDefault, +Page which is using the / route and +onCreateGlobalContext.client to no avail.Currently these are my thoughts:
Thank you for reading my rant!
Beta Was this translation helpful? Give feedback.
All reactions