From 9c1c9b4c09fca6c6e712dd3f5d98352fe1ebe15b Mon Sep 17 00:00:00 2001 From: Daniel Playfair Cal Date: Tue, 2 Oct 2018 15:38:53 +1000 Subject: [PATCH] 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. --- README.md | 3 ++- src/index.js | 25 +++++++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index beb5620a..140325a6 100644 --- a/README.md +++ b/README.md @@ -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: { diff --git a/src/index.js b/src/index.js index c905bb82..612fbfd4 100644 --- a/src/index.js +++ b/src/index.js @@ -113,6 +113,7 @@ class MiniCssExtractPlugin { this.options = Object.assign( { filename: '[name].css', + orderWarning: true, }, options ); @@ -480,16 +481,20 @@ 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')}` - ) - ); + 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); } }