Skip to content

Commit c321a55

Browse files
hedgepigdanielScriptedAlchemy
authored andcommitted
Add a orderWarnings flag to disable warnings about CSS import order (#108)
1 parent 6caeeca commit c321a55

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ module.exports = {
9090
// both options are optional
9191
filename: "[name].css",
9292
chunkFilename: "[id].css",
93-
hot: true // optional as the plugin cannot automatically detect if you are using HOT, not for production use
93+
hot: true, // optional as the plugin cannot automatically detect if you are using HOT, not for production use
94+
orderWarning: true, // Disable to remove warnings about conflicting order between imports
9495
}
9596
),
9697
]

src/index.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class CssModuleFactory {
128128

129129
class ExtractCssChunks {
130130
constructor(options) {
131-
this.options = Object.assign({ filename: '[name].css' }, options);
131+
this.options = Object.assign({ filename: '[name].css', orderWarning: true }, options);
132132
const { cssModules, reloadAll } = this.options;
133133

134134
if (!this.options.chunkFilename) {
@@ -523,16 +523,18 @@ class ExtractCssChunks {
523523
// use list with fewest failed deps
524524
// and emit a warning
525525
const fallbackModule = bestMatch.pop();
526-
compilation.warnings.push(
527-
new Error(
528-
`chunk ${chunk.name || chunk.id} [mini-css-extract-plugin]\n` +
529-
'Conflicting order between:\n' +
530-
` * ${fallbackModule.readableIdentifier(requestShortener)}\n` +
531-
`${bestMatchDeps
532-
.map(m => ` * ${m.readableIdentifier(requestShortener)}`)
533-
.join('\n')}`,
534-
),
535-
);
526+
if (this.options.orderWarning) {
527+
compilation.warnings.push(
528+
new Error(
529+
`chunk ${chunk.name || chunk.id} [mini-css-extract-plugin]\n` +
530+
'Conflicting order between:\n' +
531+
` * ${fallbackModule.readableIdentifier(requestShortener)}\n` +
532+
`${bestMatchDeps
533+
.map(m => ` * ${m.readableIdentifier(requestShortener)}`)
534+
.join('\n')}`,
535+
),
536+
);
537+
}
536538
usedModules.add(fallbackModule);
537539
}
538540
}

0 commit comments

Comments
 (0)