Skip to content

Commit

Permalink
feat: add orderWarnings flag
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hedgepigdaniel committed Mar 26, 2019
1 parent 272910c commit 503dec2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ module.exports = {
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "[name].css",
chunkFilename: "[id].css"
chunkFilename: "[id].css",
orderWarning: true // Disable to remove warnings about conflicting order
})
],
module: {
Expand Down
27 changes: 16 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class MiniCssExtractPlugin {
this.options = Object.assign(
{
filename: '[name].css',
orderWarning: true,
},
options
);
Expand Down Expand Up @@ -480,17 +481,21 @@ class MiniCssExtractPlugin {
// use list with fewest failed deps
// and emit a warning
const fallbackModule = bestMatch.pop();
compilation.warnings.push(
new Error(
`chunk ${chunk.name || chunk.id} [mini-css-extract-plugin]\n` +
'Conflicting order between:\n' +
` * ${fallbackModule.readableIdentifier(requestShortener)}\n` +
`${bestMatchDeps
.map((m) => ` * ${m.readableIdentifier(requestShortener)}`)
.join('\n')}`
)
);
usedModules.add(fallbackModule);
if (this.options.orderWarning) {
compilation.warnings.push(
new Error(
`chunk ${chunk.name || chunk.id} [mini-css-extract-plugin]\n` +
'Conflicting order between:\n' +
` * ${fallbackModule.readableIdentifier(
requestShortener
)}\n` +
`${bestMatchDeps
.map((m) => ` * ${m.readableIdentifier(requestShortener)}`)
.join('\n')}`
)
);
usedModules.add(fallbackModule);
}
}
}
} else {
Expand Down

0 comments on commit 503dec2

Please sign in to comment.