Skip to content

Commit

Permalink
fix(@angular/cli): fix problem of SuppressPlugin in case entryFiles t…
Browse files Browse the repository at this point in the history
…ype is string (#7393)

The type of entryFiles from entryPoint is array in webpack official suggested, but actually it could be string. The error caused by `every` method which is only invoked by array, however entryFiles is a string. Solution: if entryFiles is not array, make it as an array which includes just a single string element.
  • Loading branch information
dcalsky authored and Brocco committed Aug 17, 2017
1 parent 5752d18 commit 310dd81
Showing 1 changed file with 10 additions and 7 deletions.
Expand Up @@ -8,14 +8,17 @@ export class SuppressExtractedTextChunksWebpackPlugin {
compiler.plugin('compilation', function (compilation: any) {
// find which chunks have css only entry points
const cssOnlyChunks: string[] = [];
const entryPoints = compilation.options.entry;
// determine which entry points are composed entirely of css files
for (let entryPoint of Object.keys(entryPoints)) {
if (entryPoints[entryPoint].every((el: string) =>
el.match(/\.(css|scss|sass|less|styl)$/))) {
cssOnlyChunks.push(entryPoint);
}
const entryPoints = compilation.options.entry;
// determine which entry points are composed entirely of css files
for (let entryPoint of Object.keys(entryPoints)) {
let entryFiles: string[]|string = entryPoints[entryPoint];
// when type of entryFiles is not array, make it as an array
entryFiles = entryFiles instanceof Array ? entryFiles : [entryFiles];
if (entryFiles.every((el: string) =>
el.match(/\.(css|scss|sass|less|styl)$/) !== null)) {
cssOnlyChunks.push(entryPoint);
}
}
// Remove the js file for supressed chunks
compilation.plugin('after-seal', (callback: any) => {
compilation.chunks
Expand Down

0 comments on commit 310dd81

Please sign in to comment.