Skip to content

Commit 9c37719

Browse files
hedgepigdanielScriptedAlchemy
authored andcommitted
feat: add orderWarnings flag (#158)
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 1428e11 commit 9c37719

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/index.js

+17-12
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class ExtractCssChunksPlugin {
113113
this.options = Object.assign(
114114
{
115115
filename: '[name].css',
116+
orderWarning: true,
116117
},
117118
options
118119
);
@@ -495,18 +496,22 @@ class ExtractCssChunksPlugin {
495496
// use list with fewest failed deps
496497
// and emit a warning
497498
const fallbackModule = bestMatch.pop();
498-
compilation.warnings.push(
499-
new Error(
500-
`chunk ${chunk.name ||
501-
chunk.id} [extract-css-chunks-webpack-plugin]\n` +
502-
'Conflicting order between:\n' +
503-
` * ${fallbackModule.readableIdentifier(requestShortener)}\n` +
504-
`${bestMatchDeps
505-
.map((m) => ` * ${m.readableIdentifier(requestShortener)}`)
506-
.join('\n')}`
507-
)
508-
);
509-
usedModules.add(fallbackModule);
499+
if (this.options.orderWarning) {
500+
compilation.warnings.push(
501+
new Error(
502+
`chunk ${chunk.name ||
503+
chunk.id} [extract-css-chunks-webpack-plugin]\n` +
504+
'Conflicting order between:\n' +
505+
` * ${fallbackModule.readableIdentifier(
506+
requestShortener
507+
)}\n` +
508+
`${bestMatchDeps
509+
.map((m) => ` * ${m.readableIdentifier(requestShortener)}`)
510+
.join('\n')}`
511+
)
512+
);
513+
usedModules.add(fallbackModule);
514+
}
510515
}
511516
}
512517
} else {

0 commit comments

Comments
 (0)