Skip to content
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

CSS injection order issue between dev & prod #21627

Closed
1 of 2 tasks
jankaifer opened this issue Jun 30, 2020 · 1 comment
Closed
1 of 2 tasks

CSS injection order issue between dev & prod #21627

jankaifer opened this issue Jun 30, 2020 · 1 comment
Labels
package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5. support: question Community support but can be turned into an improvement

Comments

@jankaifer
Copy link

jankaifer commented Jun 30, 2020

When you import your code before material ui, production build will make materialui's styles more important and development build will make your styles more important.

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

The order of is different in production and development.

Expected Behavior 🤔

It should be the same.

Steps to Reproduce 🕹

Steps:

https://codesandbox.io/s/naughty-glade-mf8mq?file=/src/PaddedPaper.js
Deployed codesanbox with Vercel: https://csb-mf8mq-ahng75pjv.vercel.app/

  1. Create component A with custom styles
  2. import that component before material ui component B
  3. use
  4. Compare production and development build (in production styles from B will be more important in the development the styles of A will be more important)

Context 🔦

Just spend weekend debugging why is my production is broken and development works fine.

Your Environment 🌎

Used provided sandbox template (it has material v5 alpha but it is reproducible in v4 as well).
Browser: Brave Version 1.10.93 Chromium: 83.0.4103.106 (Official Build) (64-bit)

@jankaifer jankaifer added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jun 30, 2020
@oliviertassinari oliviertassinari added package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5. and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jun 30, 2020
@oliviertassinari oliviertassinari changed the title Development and production builds have different styles. CSS injection order issue between dev & prod Jun 30, 2020
@oliviertassinari
Copy link
Member

@jankaifer This is expected, the CSS injection order is dictated by the import order. In your case, it seems that something in the production resolution pipeline changes the order, maybe tree-shaking. You can find more details on #16374 (comment).

I'm not sure how we could better document it. It doesn't seem to be a frequent problem. Maybe having developers searching on the GitHub's issue history is enough 🤔

@oliviertassinari oliviertassinari added the support: question Community support but can be turned into an improvement label Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5. support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

2 participants