diff --git a/lib/karma-webpack.js b/lib/karma-webpack.js index 8edcbfa..40f52e3 100644 --- a/lib/karma-webpack.js +++ b/lib/karma-webpack.js @@ -80,9 +80,19 @@ function preprocessorFactory(config, emitter) { controller.karmaEmitter = emitter; } + const transformPath = + config.webpack.transformPath || + ((filepath) => { + // for *.js files by default + const info = path.parse(filepath); + return `${path.join(info.dir, info.name)}.js`; + }); + return async function processFile(content, file, done) { await controller.bundle(); + file.path = transformPath(file.path); // eslint-disable-line no-param-reassign + const bundleContent = controller.bundlesContent[path.parse(file.path).base]; done(null, bundleContent); };