Last active
May 5, 2021 20:58
-
-
Save MantasMikal/2108a2ef8ce0ee3196ee23e1d75fa732 to your computer and use it in GitHub Desktop.
Ignore mini-css-extract-plugin warnings on Gatsby 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
You may be using CSS Modules or another CSS-in-JS library to safely scope CSS between pages and components. | |
The webpack mini-css-extract-plugin still warns that the CSS might be bundled out of order. | |
Warnings look like this: | |
warn chunk commons [mini-css-extract-plugin] | |
Conflicting order. Following module has been added: | |
* css ./node_modules/gatsby/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[9].oneOf[0].use[1]!./node_modules/gatsby/node_modules/postcss-l | |
oader/dist/cjs.js??ruleSet[1].rules[9].oneOf[0].use[2]!./node_modules/gatsby-plugin-sass/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[9] | |
.oneOf[0].use[3]!./src/components/Primitive/Container/Container.module.scss | |
To silence them, add the following code to your gatsby-node.js | |
*/ | |
/** Removes Mini-css errors */ | |
exports.onCreateWebpackConfig = ({ stage, actions, getConfig }) => { | |
if (stage === 'develop' || stage === 'build-javascript') { | |
const config = getConfig() | |
const miniCssExtractPlugin = config.plugins.find( | |
(plugin) => plugin.constructor.name === 'MiniCssExtractPlugin' | |
) | |
if (miniCssExtractPlugin) { | |
miniCssExtractPlugin.options.ignoreOrder = true | |
} | |
actions.replaceWebpackConfig(config) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment