Skip to content

Commit

Permalink
feat: add orderWarnings flag (#158)
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 authored and ScriptedAlchemy committed Mar 27, 2019
1 parent 1428e11 commit 9c37719
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class ExtractCssChunksPlugin {
this.options = Object.assign(
{
filename: '[name].css',
orderWarning: true,
},
options
);
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9c37719

Please sign in to comment.