Skip to content

Commit 0075d6f

Browse files
JSMikeMichael Cebrian
authored and
Michael Cebrian
committed
fix(karma): set defaults for karma.conf.js
The karma plugin is currently overwriting configuration set in karma.conf.js instead of merging existing values. This fix will set defaults but not overwrite existing configuration.
1 parent 5ac060b commit 0075d6f

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

plugins/karma.js

+22-14
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,27 @@ const init = (config) => {
99
const appConfig = angularCliConfig.apps[0];
1010

1111
// add webpack config
12-
config.webpack = getWebpackTestConfig(config.basePath, appConfig);
13-
config.webpackMiddleware = {
14-
noInfo: true, // Hide webpack output because its noisy.
15-
stats: { // Also prevent chunk and module display output, cleaner look. Only emit errors.
16-
assets: false,
17-
colors: true,
18-
version: false,
19-
hash: false,
20-
timings: false,
21-
chunks: false,
22-
chunkModules: false
23-
}
24-
};
12+
config.webpack = Object.assign(
13+
{},
14+
getWebpackTestConfig(config.basePath, angularCliConfig.defaults.sourceDir),
15+
config.webpack
16+
);
17+
config.webpackMiddleware = Object.assign(
18+
{},
19+
{
20+
noInfo: true, // Hide webpack output because its noisy.
21+
stats: { // Also prevent chunk and module display output, cleaner look. Only emit errors.
22+
assets: false,
23+
colors: true,
24+
version: false,
25+
hash: false,
26+
timings: false,
27+
chunks: false,
28+
chunkModules: false
29+
}
30+
},
31+
config.webpackMiddleware
32+
);
2533

2634
// replace the angular-cli preprocessor with webpack+sourcemap
2735
Object.keys(config.preprocessors)
@@ -40,4 +48,4 @@ preprocessor.$inject = []
4048
module.exports = Object.assign({
4149
'framework:angular-cli': ['factory', init],
4250
'preprocessor:angular-cli': ['factory', preprocessor]
43-
}, require('karma-webpack'), require('karma-sourcemap-loader'));
51+
}, require('karma-webpack'), require('karma-sourcemap-loader'));

0 commit comments

Comments
 (0)