Resolving mini‑css‑extract‑plugin Warnings in Gatsby

Image by Vadim Bogulov.

When developing applications, especially with frameworks like Gatsby JS, it wouldn't be unusual to encounter various warnings in your terminal during the build process. These are messages from tools such as webpack, giving you a headsup that there might be a potential issue, or suboptimal practices in your code.

Whilst some warnings could indicate serious problems that need to be addressed urgently, others are less critical and do not impact the functionality of your application at all.

In the case of developing with Gatsby, I've often come across this type of warning, originating from the mini-css-extract-plugin:

warn chunk commons [mini-css-extract-plugin]Conflicting order. Following module has been added: * css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[9].oneOf[1].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[9].oneOf[1].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[9].oneOf[1].use[3]!./src/components/SkipLinks/skip-links.scssdespite it was not able to fulfill desired ordering with these modules

What Causes These Warnings?

These warnings arise because mini-css-extract-plugin cannot satisfy the relative order requested for extracted styles across chunks. CSS Modules reduce selector collisions, but they do not make order irrelevant: global selectors, :global rules, composition, shared variables, and side effects can still depend on the cascade.

The warning means mini-css-extract-plugin found an ordering conflict; it does not prove that the rendered result is wrong or harmless. Trace the named modules, inspect their selectors and imports, and compare representative pages at relevant breakpoints before deciding whether the cascade is genuinely orderindependent.

In my case, the warnings could be many, many screens long, burying more important messages from webpack in masses of irrelevant warnings.

Screenshot of Terminal displaying Conflicting Order warnings coming from mini-css-extract-plugin in a Gatsby project.

Diagnose Before Suppressing

Start by finding every selector named by the warning and checking the affected routes in both possible import orders. Fix conflicting global rules or make the intended cascade explicit. Suppression is appropriate only after that review shows the extracted styles are orderindependent.

Once that verification is documented, webpack-filter-warnings-plugin can filter this specific warning from webpack output. It does not repair a cascade conflict; it only hides the message already shown to be nonactionable for this project.

After verifying order independence, there are two configuration steps to suppress the known warning:

Install webpack-filter-warnings-plugin

If you've installed a dependency before you'll already know how to do this:

yarn add -D webpack-filter-warnings-plugin

Of course if you're using npm, then the command is eversoslightly different...

Configure it in gatsby-node.ts

Now, all you need to do is configure it in your gatsby-node.ts (or gatsby-node.js) file in your webpack configuration:

const FilterWarningsPlugin = require('webpack-filter-warnings-plugin');exports.onCreateWebpackConfig = ({ actions }) => {  actions.setWebpackConfig({    plugins: [      new FilterWarningsPlugin({        exclude: /mini-css-extract-plugin[^]*Conflicting order. Following module has been added:/,      }),    ],  });};

Restart Gatsby, confirm that only the reviewed warning is filtered, and repeat the route and breakpoint checks against the built CSS. Keep the verification with the configuration so a later stylesheet change does not turn the suppression into a blind spot.


Why Not Use stats.warningsFilter?

stats.warningsFilter is a builtin configuration in webpack for filtering warnings exactly what we've been discussing. However, it is not respected by all tools and configurations. In the case of Gatsby, the default webpack configuration does not inherently support stats.warningsFilter because of the multiple stages and customisations Gatsby uses for different build processes​. (Gatsby)​​ (RelativeCI)​​ (GitHub).

Because of this, webpack-filter-warnings-plugin can be a practical way to filter one specifically reviewed warning during compilation. Keep the expression narrow, record why order is safe, and revisit the exception whenever the relevant styles or build tooling change.


Check the Warning Before Hiding It

A conflictingorder warning can be harmless, but it can also be pointing at a real cascade problem. Before suppressing it, check whether the affected CSS depends on import order. If two files define the same selector or rely on side effects, the warning may be telling you something useful.

Suppressing build noise is defensible when the team has verified the output and the warning is not actionable. It is less defensible when it becomes a way to keep CI green without understanding the stylesheet order.


Current Gatsby Context

This remains Gatsby and webpackspecific advice. If the project is already being modernised, I would treat repeated CSS extraction warnings as part of a wider styling review: CSS Modules, global imports, component boundaries and whether the build pipeline still fits the application.


Have a complex web platform issue?

Tell me what is blocked, what has changed, and what needs to be true after the fix. I'll come back with a practical next step.