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.

Styles broken in CRA Production Build but work fine in development mode

See original GitHub issue

My 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.0
  • react version: 17.0.1
  • react-scripts version: 4.0.1
  • typescript version: ^4.1.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
n8sabescommented, Jan 23, 2021

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

0reactions
zhdanouskikhcommented, Feb 10, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

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