Skip to content

Commit

Permalink
fix(karma-webpack): handle multiple outputs correctly (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
alabbas-ali authored and ryanclark committed Nov 20, 2018
1 parent d42c541 commit 41edac8
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/karma-webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ let isBlocked = false;

const normalize = (file) => file.replace(/\\/g, '/');

const getOutputPath = (outputPath) => {
for (var i = 0; i < outputPath.length; i++) {
if (
outputPath[i].indexOf(".js") !== -1 &&
outputPath[i].indexOf(".js.map") === -1
) {
return outputPath[i];
}
}
return null;
}

const escapeRegExp = function(str) {
// See details here https://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
Expand Down Expand Up @@ -169,9 +181,14 @@ function Plugin(

if (this.entries.has(entry)) {
const entryPath = this.entries.get(entry);
const outputPath = stats.assetsByChunkName[entry];

this.outputs.set(entryPath, outputPath);
let outputPath = stats.assetsByChunkName[entry];

if (Array.isArray(outputPath)) {
outputPath = getOutputPath(outputPath);
}
if (outputPath !== null) {
this.outputs.set(entryPath, outputPath);
}
}
}

Expand Down

0 comments on commit 41edac8

Please sign in to comment.