emotion: Missing styles in production (NextJS + Chakra)
Current behavior:
Styles present in development:

Are missing in production:

To reproduce:

The only difference between the menus are depending on the auth state: showing or not additionnal button actions. I suspect something is breaking the style in the Menu component. But I tried a lot of things, I don’t understand what’s the issue…
https://github.com/binajmen/chakra-nextjs/blob/develop/components/layout/Menu.tsx
Note that in development (yarn dev), I have no styling issue.
Expected behavior:
Environment information:
"dependencies": {
"@chakra-ui/react": "^1.3.3",
"@emotion/react": "^11.1.5",
"@emotion/styled": "^11.1.5",
"emotion-theming": "^11.0.0",
"next": "^10.0.7",
"react": "17.0.1",
"react-dom": "17.0.1",
...
},
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (6 by maintainers)
Fixed by putting the following in my
package.json:Execute this script asap in your app:
and inspect the call stack for both calls to this setter
From what I understand the format of the
yarn.lock:@emotion/reactandreact-selectand lists their requirements on@emotion/cache(it’s basically a copy of their respectivepackage.json#dependencies)@emotion/cacheit finally resolved (notice that theversionfield has no modifier like^as this is the final, resolved, version that was actually installed)Usually, if you end up with multiple copies of a particular library then you have multiple entries like the first one for that particular library.
I’m afraid that digging into this further would take me a considerable amount of time that I don’t currently have. I could consider diving into this if you would sponsor my work though.
Hi @Andarist,
Thank you for your input. I’ve never played with webpack before, nor on this project. I believe in NextJS, you can adapt webpack by modifying
next.config.js. In my case, the content is very light.Regarding
@emotion/cache, you mentioned in another issue (can’t find back the link) that having differentcacheversion could be an issue (IF I remember correctly… I’ve read a lot of things in the past 48 hours 🤭 ). Could it be the case?