Skip to content

Commit c8cfdb3

Browse files
Ambroosjahredhope
authored andcommitted
Select JS chunk for rendering (#138)
fixes a bug with webpack 4 + mini-css-extract-plugin
1 parent ee7b961 commit c8cfdb3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ var findAsset = function(src, compilation, webpackStatsJson) {
132132
// Webpack outputs an array for each chunk when using sourcemaps
133133
if (chunkValue instanceof Array) {
134134
// Is the main bundle always the first element?
135-
chunkValue = chunkValue[0];
135+
chunkValue = chunkValue.find(function(filename) {
136+
return /\.js$/.test(filename);
137+
});
136138
}
137139
return compilation.assets[chunkValue];
138140
};
@@ -145,8 +147,10 @@ var getAssetsFromCompilation = function(compilation, webpackStatsJson) {
145147

146148
// Webpack outputs an array for each chunk when using sourcemaps
147149
if (chunkValue instanceof Array) {
148-
// Is the main bundle always the first element?
149-
chunkValue = chunkValue[0];
150+
// Is the main bundle always the first JS element?
151+
chunkValue = chunkValue.find(function(filename) {
152+
return /\.js$/.test(filename);
153+
});
150154
}
151155

152156
if (compilation.options.output.publicPath) {

0 commit comments

Comments
 (0)