Styles broken in CRA Production Build but work fine in development mode
See original GitHub issueMy CRA-based PWA application with emotion styles works perfectly during development yarn start
, however when built for production yarn build
and served, the styles are missing when inspected in the browser. The HTML is correctly formed with references to style names (same as dev build), but the style object does not exist in the execution environment context.
I do not (yet) have a pared-down example to reproduce but will work toward that. I am posting this as inquiry to see if anybody else has come across this issue for potential pointers as to causes and/or resolution. I’ve read potential issues with importing .css files so tried removing all those, but get the same results. I do not see any errors emitted to the console/log.
@emotion/react
version: 11.1.4@emotion/styled
version: 11.0.0react
version: 17.0.1react-scripts
version: 4.0.1typescript
version: ^4.1.3
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
React Styled Components stripped out from production build
The Styled Components library uses something called the "Speedy mode" to inject styles on production. This makes the styles bypass the DOM` ...
Read more >Creating a Production Build - Create React App
npm run build creates a build directory with a production build of your app. Inside the build/static directory will be your JavaScript and...
Read more >4 Reasons Why You Should Prefer Vite Over Create-React ...
Unlike CRA, Vite does not build your entire application before serving, instead, it builds the application on demand.
Read more >How to fix the Whitescreen After a Static Deployment with ...
It's one of the most annoying situations after deploying a static React app: After all that work, you finally deployed your app for ......
Read more >How to Upgrade to React 18
If removing Strict Mode fixes your app, you can remove it during the upgrade, and then add it back (either at the top...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Wrapping the app in a
CacheProvider
worked! Thank you @Andarist.Should I close this issue, or is there something to be done to improve the library (e.g. context overwriting, naming convention, etc.)?
Are there any updates on how to fix this issue? For me it reproduced only in mobile Safari and I wrapped the app in CacheProvider.
I’m using emotion with mui 5 and tss-react.