Skip to content

Commit 310dd81

Browse files
dcalskyBrocco
authored andcommitted
fix(@angular/cli): fix problem of SuppressPlugin in case entryFiles type 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.
1 parent 5752d18 commit 310dd81

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

packages/@angular/cli/plugins/suppress-entry-chunks-webpack-plugin.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ export class SuppressExtractedTextChunksWebpackPlugin {
88
compiler.plugin('compilation', function (compilation: any) {
99
// find which chunks have css only entry points
1010
const cssOnlyChunks: string[] = [];
11-
const entryPoints = compilation.options.entry;
12-
// determine which entry points are composed entirely of css files
13-
for (let entryPoint of Object.keys(entryPoints)) {
14-
if (entryPoints[entryPoint].every((el: string) =>
15-
el.match(/\.(css|scss|sass|less|styl)$/))) {
16-
cssOnlyChunks.push(entryPoint);
17-
}
11+
const entryPoints = compilation.options.entry;
12+
// determine which entry points are composed entirely of css files
13+
for (let entryPoint of Object.keys(entryPoints)) {
14+
let entryFiles: string[]|string = entryPoints[entryPoint];
15+
// when type of entryFiles is not array, make it as an array
16+
entryFiles = entryFiles instanceof Array ? entryFiles : [entryFiles];
17+
if (entryFiles.every((el: string) =>
18+
el.match(/\.(css|scss|sass|less|styl)$/) !== null)) {
19+
cssOnlyChunks.push(entryPoint);
1820
}
21+
}
1922
// Remove the js file for supressed chunks
2023
compilation.plugin('after-seal', (callback: any) => {
2124
compilation.chunks

0 commit comments

Comments
 (0)