From c432dd218d247fb0bbd52f107bf9852022ea8f80 Mon Sep 17 00:00:00 2001 From: Alabbas Alhaj Ali Date: Sat, 22 Sep 2018 01:37:34 +0200 Subject: [PATCH 1/4] uplift multiple output files fix to the 4.x branch --- src/karma-webpack.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/karma-webpack.js b/src/karma-webpack.js index 4133442..006594f 100644 --- a/src/karma-webpack.js +++ b/src/karma-webpack.js @@ -18,6 +18,15 @@ let isBlocked = false; const normalize = (file) => file.replace(/\\/g, '/'); +var getJsOutput = (outputPathArray) => { + for (var _i = 0; _i < outputPathArray.length; _i++) { + if (outputPathArray[_i].indexOf(".js") != -1) { + return outputPathArray[_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, '\\$&'); @@ -170,8 +179,11 @@ function Plugin( if (this.entries.has(entry)) { const entryPath = this.entries.get(entry); const outputPath = stats.assetsByChunkName[entry]; - - this.outputs.set(entryPath, outputPath); + + if (Array.isArray(outputPath)) + outputPath = getJsOutput(outputPath); + if (outputPath != null) + this.outputs.set(entryPath, outputPath); } } From 55d42c147b7b9b98754475b8027656bb2ffde7a7 Mon Sep 17 00:00:00 2001 From: Alabbas Alhaj Ali Date: Sat, 22 Sep 2018 21:00:25 +0200 Subject: [PATCH 2/4] [v4.x] fix(karma-webpack): fix review comments, fix handling .js.map output --- src/karma-webpack.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/karma-webpack.js b/src/karma-webpack.js index 006594f..88b1a3f 100644 --- a/src/karma-webpack.js +++ b/src/karma-webpack.js @@ -18,10 +18,13 @@ let isBlocked = false; const normalize = (file) => file.replace(/\\/g, '/'); -var getJsOutput = (outputPathArray) => { - for (var _i = 0; _i < outputPathArray.length; _i++) { - if (outputPathArray[_i].indexOf(".js") != -1) { - return outputPathArray[_i] +var 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 @@ -181,8 +184,8 @@ function Plugin( const outputPath = stats.assetsByChunkName[entry]; if (Array.isArray(outputPath)) - outputPath = getJsOutput(outputPath); - if (outputPath != null) + outputPath = getOutputPath(outputPath); + if (outputPath !== null) this.outputs.set(entryPath, outputPath); } } From 46963fa2acfd39b2ce4ec612ec14b04b778da2ed Mon Sep 17 00:00:00 2001 From: Alabbas Alhaj Ali Date: Thu, 18 Oct 2018 10:10:10 +0200 Subject: [PATCH 3/4] v4 multiple output files, fix review comments --- src/karma-webpack.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/karma-webpack.js b/src/karma-webpack.js index 88b1a3f..07db1ff 100644 --- a/src/karma-webpack.js +++ b/src/karma-webpack.js @@ -18,16 +18,16 @@ let isBlocked = false; const normalize = (file) => file.replace(/\\/g, '/'); -var getOutputPath = (outputPath) => { +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 outputPath[i]; } } - return null + return null; } const escapeRegExp = function(str) { @@ -183,10 +183,12 @@ function Plugin( const entryPath = this.entries.get(entry); const outputPath = stats.assetsByChunkName[entry]; - if (Array.isArray(outputPath)) + if (Array.isArray(outputPath)) { outputPath = getOutputPath(outputPath); - if (outputPath !== null) + } + if (outputPath !== null) { this.outputs.set(entryPath, outputPath); + } } } From e2f4cdc9f18be23c71515644676b4982640b3d2f Mon Sep 17 00:00:00 2001 From: Alabbas Alhaj Ali Date: Wed, 24 Oct 2018 09:29:16 +0200 Subject: [PATCH 4/4] Removing linter warnings --- src/karma-webpack.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/karma-webpack.js b/src/karma-webpack.js index 07db1ff..de842fe 100644 --- a/src/karma-webpack.js +++ b/src/karma-webpack.js @@ -181,7 +181,7 @@ function Plugin( if (this.entries.has(entry)) { const entryPath = this.entries.get(entry); - const outputPath = stats.assetsByChunkName[entry]; + let outputPath = stats.assetsByChunkName[entry]; if (Array.isArray(outputPath)) { outputPath = getOutputPath(outputPath);