-
Notifications
You must be signed in to change notification settings - Fork 318
How do I ignoreOrder
in next.js?
#506
Comments
@uyouthe can you show your |
@frnk94 here it is: const { PHASE_PRODUCTION_BUILD } = require('next-server/constants');
const withPlugins = require('next-compose-plugins');
const typescript = require('@zeit/next-typescript');
const css = require('@zeit/next-css');
const getLocalIdent = require('css-loader/lib/getLocalIdent');
const config = require('config');
module.exports = withPlugins([typescript, css], {
env: {
basePath: config.get('basePath'),
},
distDir: '../.next',
assetPrefix: config.get('development') ? '' : config.get('basePath'),
cssModules: true,
cssLoaderOptions: {
importLoaders: 1,
localIdentName: '[local]___[hash:base64:5]',
camelCase: true,
getLocalIdent: (loaderContext, localIdentName, localName, options) => {
// HOTFIX: import css classes from react components as-is
if (loaderContext.resourceQuery === '?raw-class-name') {
return localName;
}
return getLocalIdent(loaderContext, localIdentName, localName, options);
},
},
[PHASE_PRODUCTION_BUILD]: {
cssLoaderOptions: {
importLoaders: 1,
localIdentName: '[local]___[hash:base64:5]',
camelCase: true,
getLocalIdent: (loaderContext, localIdentName, localName, options) => {
// HOTFIX: import css classes from react components as-is
if (loaderContext.resourceQuery === '?raw-class-name') {
return localName;
}
return getLocalIdent(loaderContext, localIdentName, localName, options);
},
},
},
webpack(config) {
const originalEntry = config.entry;
config.entry = async () => {
const entries = await originalEntry();
if (
entries['main.js'] &&
!entries['main.js'].includes('./polyfills.js')
) {
entries['main.js'].unshift('./polyfills.js');
}
return entries;
};
config.module.rules.push({
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader',
});
config.stats = {
// HOTFIX: https://github.com/webpack-contrib/mini-css-extract-plugin/issues/250
warningsFilter: (warning) => /Conflicting order between/m.test(warning),
};
return config;
},
}); Now I'm in transition between Styled and CSS Modules, so there are some hotfixes, and there's a hotfix to mute some warnings. But I don't want to mute them. I want to actually get rid of them because of styling issues I mentioned above. |
+1 on this. Anyone have any ideas where to put this flag? |
There is no I think you don't need this flag after upgrading the package (= |
@gwer the issue remains: it just says
instead of
|
This change should fix conflicting order error in ExtractCssChunksPlugin (vercel#506)
Are you sure that suppressing error will fix problem? You can try to update |
This change should fix conflicting order error in ExtractCssChunksPlugin (vercel#506)
@gwer Thanks for the fix! Ignoring the warnings doesn't necessarily fix the problem, but it has been added because if you are vigilant about scoping and unique naming conventions then it shouldn't be an issue. Definitely not ideal. webpack-contrib/mini-css-extract-plugin#422. |
Will be great to pass options to MiniCssExtractPlugin, e.g. |
Any progress of this problem? |
I've given up on next.js because of lack of support |
@gwer when I pull next-css from npm, the version is 1.0.1 but I believe the update you mentioned is part of 1.0.2-canary.2 when I look at the source you shared - thanks for the tip!
Actually its next-sass that lists 1.0.1 of next-css as a dependency so if you're also using next-sass I guess we'll need to get
|
ok that didn't work - now instead of complaining about the mini-css-extract plugin, it complains about extract-css-chunks-webpack-plugin
|
What finally worked for me... In the package.json I decided to simply set it go with the latest
After finding this fix, I did:
...and now I'm back in business. I apologize that my issue isn't exactly what the original poster asked but it may solve your issue if you don't want to mess with webpack. |
I am feeling demotivated while working with the next js. |
[email protected] come with Built-In CSS Support. However if you can't upgrade and just want to silence those error you can add this config: // next.config.js
const withCSS = require("@zeit/next-css");
const FilterWarningsPlugin = require("webpack-filter-warnings-plugin");
const nextConfig = {
webpack: (config) => {
config.plugins.push(
new FilterWarningsPlugin({
exclude: /mini-css-extract-plugin[^]*Conflicting order between:/
})
);
return config;
}
}
module.exports = withCSS(nextConfig); |
We can configure like this. It works for me.
|
This worked for me. Even though I'm not having the warnings anymore, should I be concerned that I still have conflicts lurking behind the scenes? I still don't think I adequately understand what is actually causing this warning. |
I'm closing this because of [email protected] |
i do that, but not work! antd: 4.3.4 |
still having the issue with next 9.5.5 |
The
Conflicting order between
issue ofmini-css-extract-plugin
seems to be the common problem of our developer base.However, there's a possible fix released just about two weeks ago.
How do I integrate it? I'm struggling with finding an exact place in config where I should put
ignoreOrder: true
.To Reproduce
yarn build
Expected behavior
I don't want this warnings. This issue is the reason I have problems with styles in my Next.js projects: CSS sometimes doesn't apply.
System information
Help is needed urgently and highly appreciated.
The text was updated successfully, but these errors were encountered: