Open
Description
(react-scripts 2.0.4)
Same as in this issue I am getting a lot of errors from the mini-css-extract-plugin when doing a CI build - which fails since no warnings are allowed.
Since CRA does not allow customizing the WebPack plugin config, I cannot use the warningsFilters and the question about CRA also already popped up.
I am not sure what the CRA team can do about this - but maybe just keep an eye on it (or have it documented as a Known Issue) until WebPack somehow solves it.
PS: for now I am running "set CI=&&react-scripts build" to disable the CI build warnings limit.
Activity
andriijas commentedon Oct 12, 2018
Are you using 3rd party styling library like antd, bootstrap or anything else?
Like mentioned in the related issue webpack-contrib/mini-css-extract-plugin#250 (comment) the problem should not just be ignored by disabling and hiding the warnings but addressing the source cause instead, its not healthy to have fragile and inconsistent builds.
holloway commentedon Oct 14, 2018
@dviry fyi I solved this by importing all CSS from a single file, and for code-split styles I'll migrate to a CSS-in-JS approach (probably
Glamorstyled-components
).Timer commentedon Oct 15, 2018
Yeah, this is a very valid problem. A light change in your code could alter the cascading effects of your CSS, so this is warranted. Maybe some docs on how to fix it would be nice.
ryancogswell commentedon Oct 19, 2018
@Timer This seems like more than a documentation problem. I'm working on un-ejecting, but couldn't before 2.0 because of using Sass and CSS modules. Now with 2.0, I'm getting a bunch of these warnings, but we are using CSS modules for everything so there's no chance of the order actually being important (we aren't using any global styles -- just CSS classes).
ryancogswell commentedon Oct 22, 2018
In our case, I've worked around this by importing within index.js the components that directly use the CSS files that the warnings were complaining about. This resolves the order ambiguity and in my case, the components are shared pieces that are fine to be in my "main" chunk.
bogdan-calapod commentedon Nov 9, 2018
I also have this problem, and the error message is utterly useless and frustrating. On a large project it isn't feasible to randomly start requiring the devs to update their CSS based on arbitrary rules.
I'm using this with SCSS, and I'm even more confused on what it wants from me. The linked issue doesn't help much either.
stereobooster commentedon Nov 20, 2018
We use CSS Modules. The problem is in our code, but it is hard to understand what exactly is the issue. It complains about order of css imports in asset graph, but which exactly files?
Related webpack-contrib/mini-css-extract-plugin#250
theZieger commentedon Nov 27, 2018
I also had an issue with the mini-css-extract-plugin warning about a confliction order. Good thing was I'm in complete control of the component library we are using. But finding the correct spot where the problem occurs was really tough. I'm not an expert regarding webpack and neither the mini-css-extract-plugin or any of this. That's why I use CRA in the first place - I don't want to deal in detail with webpack and it's plugin ecosystem.
Nonetheless I was able to fix my component library. I'll just leave this here, so it may be some help to others hopefully.
Before the change:
BaseButton.js
IconButton.js
When I used the components in that way, the CSS generated on build was not in the order I suspected it to be. When looking at the code of IconButton.js I would assume that the build process would put BaseButton.css before IconButton.css. But in fact it was in the wrong order ... this led to wrongly applied CSS rules (because cascading). And yeah maybe I should move on to use CSS Modules.
Anyway her my solution - even though I can't explain why this works now:
BaseButton.js
IconButton.js
Maybe one of you can explain this to me or maybe this even helps you finding a similiar solution on your projects. Just wanted to share ... and this is the first issue I found regarding CRA and mini-css-extract-plugin.
gonzofish commentedon Dec 14, 2018
@theZieger what's in
Global.css
?theZieger commentedon Dec 14, 2018
@gonzofish some normalize styles but mostly custom properties (CSS variables)
114 remaining items
fix conflicting order warnings
webpack bundle: remove presumably unnecessary warnings
Sort imports
Fix conflicting order of CSS modules
Fix conflicting order of CSS modules
Ankit8969 commentedon Jul 3, 2023
I also got this issues, in my 5-6 files,
So, what i did
I create a global scss file and put all the css code in that file and delete the other,
this is how this issues got resolved
fix imports, remove unused imports
Fix: gatsby 경고메세지 해결
Fix: gatsby 경고메세지 해결
fregante commentedon Feb 8, 2025
Here's my understand and solution to the issue. It's not very straightforward because it requires you to understand how the imports appear in the code, in the entire import tree.
What's causing them?
Context:
a{color: red; color: blue}
If a build entry imports
2.css; 1.css
and the other1.css; 2.css
, the generated file can only follow one of the orders; That's what the error means.What do they cause?
If the styles actually overlapped each other, the style imported later (in the source code) wouldn't be applied because it still appeared earlier in the output CSS file.
Fix
Ensure that the order is always the same. Example:
You have to figure out which packages lead to
ReactCrop.scss
andfontawesome-svg-core.css
. In this case, I opened the two entry points for the mentioned chunksEphemeralFormContent.ts
andCustomFormComponent.ts
ReactCrop.scss
ImageCropWidget
, move it to the top of the file, in bothEphemeralFormContent.ts
andCustomFormComponent.ts
fontawesome-svg-core
importer, if the error hasn't been fixed already