Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select JS chunk with some extra logic, fixes a bug with webpack 4 + mini-css-extract-plugin #138

Merged
merged 5 commits into from
Nov 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ var findAsset = function(src, compilation, webpackStatsJson) {
// Webpack outputs an array for each chunk when using sourcemaps
if (chunkValue instanceof Array) {
// Is the main bundle always the first element?
chunkValue = chunkValue[0];
chunkValue = chunkValue.find(function(filename) {
return /\.js$/.test(filename);
});
}
return compilation.assets[chunkValue];
};
Expand All @@ -145,8 +147,10 @@ var getAssetsFromCompilation = function(compilation, webpackStatsJson) {

// Webpack outputs an array for each chunk when using sourcemaps
if (chunkValue instanceof Array) {
// Is the main bundle always the first element?
chunkValue = chunkValue[0];
// Is the main bundle always the first JS element?
chunkValue = chunkValue.find(function(filename) {
return /\.js$/.test(filename);
});
}

if (compilation.options.output.publicPath) {
Expand Down