From 49f7674259fb5dfe4babe9c010bc853ff7ebcd9a 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. --- src/index.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/index.js b/src/index.js index 468aadb8..a6e2aaf7 100644 --- a/src/index.js +++ b/src/index.js @@ -113,6 +113,7 @@ class ExtractCssChunksPlugin { this.options = Object.assign( { filename: '[name].css', + orderWarning: true, }, options ); @@ -495,18 +496,22 @@ class ExtractCssChunksPlugin { // use list with fewest failed deps // and emit a warning const fallbackModule = bestMatch.pop(); - compilation.warnings.push( - new Error( - `chunk ${chunk.name || - chunk.id} [extract-css-chunks-webpack-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} [extract-css-chunks-webpack-plugin]\n` + + 'Conflicting order between:\n' + + ` * ${fallbackModule.readableIdentifier( + requestShortener + )}\n` + + `${bestMatchDeps + .map((m) => ` * ${m.readableIdentifier(requestShortener)}`) + .join('\n')}` + ) + ); + usedModules.add(fallbackModule); + } } } } else {