ant-design: [mini-css-extract-plugin] Conflicting order between:
- I have searched the issues of this repository and believe that this is not a duplicate.
Reproduction link
Can’t reproduce
Steps to reproduce
During build process react-create-app
I receive warnings regarding Conflicts order between
styles in antd lib
What is expected?
What is actually happening?
chunk 3 [mini-css-extract-plugin]
Conflicting order between:
* css ./node_modules/css-loader??ref--7-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./node_modules/antd/lib/empty/style/index.css
* css ./node_modules/css-loader??ref--7-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./node_modules/antd/lib/select/style/index.css
Environment | Info |
---|---|
antd | 3.15.2 |
React | ^16.8.2 |
System | Ubuntu 16.04 |
Browser | Not related to browser |
Could you please fix/sort your styles
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 15
- Comments: 68 (6 by maintainers)
Is there any certain way to fix this? I’m using Next.js + Ant Design and I see a lot of warnings like this.
Also, pages sometimes don’t display properly. I think it is because of this conflict error.
+1 on using with Next.js!
Duplicate of #14895
I have found a solution for this problem ( antd + less + next )
next.config.js
.babelrc
pages/_app.js
antd-custom.less
For those who uses
react-app-rewired
or analogues and sticks to godisable mini-css-extract-plugin warning
way:"mini-css-extract-plugin": "^0.8.0"
, otherwise add it (there’s an extra flag in this version to skip ordering warnings)config-overrides.js
:@THPubs The simple way is just adding webpack-filter-warnings-plugin to ignore this warning if no other effect.
We’re experiencing this error as well. The only solution was to override the CI environment variable and set it to false in my CI Pipeline in order to get the build to pass.
@jlozanoher I think you have the warning because you import the antdesign style in .babelrc and in next.config.js.
Try to remove import of Less in .babelrc and in next.config.js.
In your _app.js import your custom less file, and in your less file import default antdesign less.
next.config.js :
.babelrc
your custom less file :
And in pages/_app.js import your less file
@ashbuilds Check my example on codesandbox here i have just one warning during the build but this is normal
next.config.js
Thats work like a charm 👍
@GermaVinsmoke ,
Already have babel-plugin-import set to
style: true
. Still have this problem. (Note: I’m using Gatsby, not next, but I believe the issue occurs regardless.)@qiwang97 I don’t think that’s a good idea. I’m missing some styles during the first page load. They load only after re-loading.
Also seeing this with gatsbyjs
@hassansaadfr that is the issue, that we failed to get it work all together: Ant + Less + Next + CSS modules.
So, I investigate this issue more deeply. And sure that this is problem is MY styles. AFAIK,
ant
generate one bundle css or chunk per route (depends on webpack configuration). And it’s not same as inMaterial-UI
which inject and encapsulate styles per component. In case withant
you need to provide this encapsulation by self. It’s can be unique class-wrapper for each component or just define all your styles in sigle fileCan we connect via skype or any medium? so that I show you my code.
If related to Antd then do these 2 things -
If you import styles by specifying the
style
option of babel-plugin-import, change it from'css'
totrue
, which will import theless
version of antd.If you import styles from
'antd/dist/antd.css'
, change it toantd/dist/antd.less
.[Edit] - Importing css files at the last.
The
next.config.js
part can be checked from this nextjs-css-less-antdWith NextJS 11.0 with Less , I’ve found excellent success with the following plugin https://github.com/SolidZORO/next-plugin-antd-less
Repo example: https://github.com/SolidZORO/mkn
+1 on using with Next.js. I have same issue!
There is now an NPM package named @webkrafters/ordercss which tackles this issue.
Full disclosure: I initially created it to solve this very problem in one of my apps but decided to expand it and share it with everyone.
If this package helps anyone, please share it with others.
Thanks and good luck!
@hassansaadfr your suggestions were the missing key ! Voilá. Now there are no warnings and no needs of pages refreshing for broken styles.
@hassansaadfr here is the code
{ “presets”: [“next/babel”] }
@Mohammed-Poolwla show me your code. Or send me a codesandbox 👍
@hassansaadfr Hi, Just tried the last fix you posted. Still the same warning.
I think this issue needs to be opened. It’s still happening.