-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Different order of emotion css files injected on local and production #2764
Comments
You can control where the styles should be injected by configuring |
Related issues:
@mknmohit What version of Next are you using? This comment says their issue was fixed in Next 12.1.6. Though, I am not 100% sure if their issue is the same as your issue. |
Next version is 12.1.0 |
Try upgrading to to 12.1.6 and let us know if that fixes it. |
@srmagura Thanks for the response. I tried again after upgrading next to |
@mknmohit Not sure if this helps but nextjs Can you try upgrading next to |
@siriwatknp I tried the |
@mknmohit I suspect that it is the configuration in your nextjs Note that the version of next should be |
A couple of own findings on this topic: mui/material-ui#32916 (comment) TLDR: I managed fix this problem by adding |
I'm running into the same issue, and honestly this makes next.js awful for me. I'd rather just use a regular vanilla React app than deal with this non sense. I spent a few hours on a small project going crazy because my production build wasn't the same as the developer run. It also seems that similar issues have been going on for years, and they just seem to close out old ones, and put them into new issues so it has less votes. |
Having same issue but without Next.js. |
Current behavior:
I am currently using nextjs
v12.1.0
material-ui (MUIv5.6.3
) along with emotionv11
and tailwindcssv3.0.15
.Emotion style/CSS files should be injected above my custom styling files so that my custom styling can have more specificity.
I observed that the order of emotion style files injected into the head tag is different on local and different on production. On local, the emotion styling files are injected on top under the head tag, which seems to be correct. But on production it is not working as expected.
I have taken screenshots of both environments.
Styling files order on Local
Styling files order on Production
Currently, my code looks something like this:
I noticed one more thing If I locally build the production using
next build
and serve the prod build locally usingnext start
, then the order of styling file is working fine, i.e. emotion styling files are getting injected at the top. But when I deploy the production build to the actual test/live environment, the order of styling files is not as expected.Expected behavior:
The order of emotion styling/css files should be injected on top of my head tag or injected above my custom styling/css files so that the specificity of my custom styling will have more priority.
Environment information:
next
version: 12.1.0react
version: 17.0.2@emotion/react
version: 11.9.0@emotion/styled
version: 11.8.1@emotion/server
version: 11.4.0@mui/material
version: 5.6.3The text was updated successfully, but these errors were encountered: