forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack-test-config.ts
39 lines (33 loc) · 1.1 KB
/
webpack-test-config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import * as webpack from 'webpack';
const webpackMerge = require('webpack-merge');
import { BuildOptions } from './build-options';
import { NgCliWebpackConfig } from './webpack-config';
import {
getCommonConfig,
getStylesConfig,
getNonAotTestConfig,
getTestConfig
} from './webpack-configs';
export interface WebpackTestOptions extends BuildOptions {
codeCoverage?: boolean;
}
export class WebpackTestConfig extends NgCliWebpackConfig {
constructor(private testOptions: WebpackTestOptions, appConfig: any) {
super(testOptions, appConfig);
}
public buildConfig() {
let webpackConfigs = [
getCommonConfig(this.wco),
getStylesConfig(this.wco),
this.getTargetConfig(this.wco),
getNonAotTestConfig(this.wco),
getTestConfig(this.testOptions)
];
this.config = webpackMerge(webpackConfigs);
delete this.config.entry;
// Remove any instance of CommonsChunkPlugin, not needed with karma-webpack.
this.config.plugins = this.config.plugins.filter((plugin: any) =>
!(plugin instanceof webpack.optimize.CommonsChunkPlugin));
return this.config;
}
}