Skip to content

Commit 9c1c9b4

Browse files
feat: add orderWarnings flag
The flag defaults to true, which retains the existing behaviour of warnings when there is conflicting import order between multiple CSS files. When set to false, these warnings are not generated.
1 parent 272910c commit 9c1c9b4

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ module.exports = {
5050
// Options similar to the same options in webpackOptions.output
5151
// both options are optional
5252
filename: "[name].css",
53-
chunkFilename: "[id].css"
53+
chunkFilename: "[id].css",
54+
orderWarning: true // Disable to remove warnings about conflicting order
5455
})
5556
],
5657
module: {

src/index.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class MiniCssExtractPlugin {
113113
this.options = Object.assign(
114114
{
115115
filename: '[name].css',
116+
orderWarning: true,
116117
},
117118
options
118119
);
@@ -480,16 +481,20 @@ class MiniCssExtractPlugin {
480481
// use list with fewest failed deps
481482
// and emit a warning
482483
const fallbackModule = bestMatch.pop();
483-
compilation.warnings.push(
484-
new Error(
485-
`chunk ${chunk.name || chunk.id} [mini-css-extract-plugin]\n` +
486-
'Conflicting order between:\n' +
487-
` * ${fallbackModule.readableIdentifier(requestShortener)}\n` +
488-
`${bestMatchDeps
489-
.map((m) => ` * ${m.readableIdentifier(requestShortener)}`)
490-
.join('\n')}`
491-
)
492-
);
484+
if (this.options.orderWarning) {
485+
compilation.warnings.push(
486+
new Error(
487+
`chunk ${chunk.name || chunk.id} [mini-css-extract-plugin]\n` +
488+
'Conflicting order between:\n' +
489+
` * ${fallbackModule.readableIdentifier(
490+
requestShortener
491+
)}\n` +
492+
`${bestMatchDeps
493+
.map((m) => ` * ${m.readableIdentifier(requestShortener)}`)
494+
.join('\n')}`
495+
)
496+
);
497+
}
493498
usedModules.add(fallbackModule);
494499
}
495500
}

0 commit comments

Comments
 (0)