diff --git a/lib/KarmaWebpackController.js b/lib/KarmaWebpackController.js index 7d71bec8..a2791dc8 100644 --- a/lib/KarmaWebpackController.js +++ b/lib/KarmaWebpackController.js @@ -18,14 +18,6 @@ class KarmaSyncPlugin { // webpack bundles are finished compiler.hooks.done.tap('KarmaSyncPlugin', async (stats) => { - // show quiter output with colors - console.log( - stats.toString({ - chunks: false, - colors: true, - }) - ); - // read generated file content and store for karma preprocessor this.controller.bundlesContent = {}; stats.toJson().assets.forEach((webpackFileObj) => { @@ -50,6 +42,10 @@ const defaultWebpackOptions = { filename: '[name].js', path: path.join(os.tmpdir(), '_karma_webpack_'), }, + stats: { + modules: false, + colors: true, + }, watch: false, optimization: { runtimeChunk: 'single', @@ -107,21 +103,18 @@ class KarmaWebpackController { } get outputPath() { - return this.__webpackOptions.output.path; + return this.webpackOptions.output.path; } constructor() { this.isActive = false; this.bundlesContent = {}; this.__debounce = false; - this.__webpackOptions = defaultWebpackOptions; + this.webpackOptions = defaultWebpackOptions; } updateWebpackOptions(newOptions) { - this.__webpackOptions = merge( - this.__webpackOptions, - newOptions - ); + this.webpackOptions = merge(this.webpackOptions, newOptions); } async bundle() { @@ -135,9 +128,9 @@ class KarmaWebpackController { async _bundle() { this.isActive = true; this.__debounce = true; - this.compiler = webpack(this.__webpackOptions); + this.compiler = webpack(this.webpackOptions); return new Promise((resolve) => { - if (this.__webpackOptions.watch === true) { + if (this.webpackOptions.watch === true) { console.log('Webpack starts watching...'); this.webpackFileWatcher = this.compiler.watch({}, (err, stats) => this.handleBuildResult(err, stats, resolve) @@ -169,6 +162,8 @@ class KarmaWebpackController { this.__debounce = setTimeout(() => (this.__debounce = false), 100); this.isActive = false; + + console.log(stats.toString(this.webpackOptions.stats)); resolve(); } diff --git a/lib/karma-webpack.js b/lib/karma-webpack.js index ea8221a2..8edcbfa6 100644 --- a/lib/karma-webpack.js +++ b/lib/karma-webpack.js @@ -42,7 +42,7 @@ function configToWebpackEntries(config) { const { preprocessors } = config; let files = []; - config.files.forEach(fileEntry => { + config.files.forEach((fileEntry) => { files = [...files, ...glob.sync(fileEntry.pattern)]; }); @@ -53,7 +53,7 @@ function configToWebpackEntries(config) { }); const filteredFiles = []; - files.forEach(filePath => { + files.forEach((filePath) => { filteredPatterns.forEach((pattern) => { if (minimatch(filePath, pattern)) { filteredFiles.push(filePath);