angular-cli/packages/@angular/cli/models/webpack-test-config.ts
2017-02-22 11:54:06 +00:00

39 lines
1.0 KiB
TypeScript

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) {
super(testOptions);
}
public buildConfig() {
let webpackConfigs = [
getCommonConfig(this.wco),
getStylesConfig(this.wco),
this.getTargetConfig(this.wco),
getNonAotTestConfig(this.wco),
getTestConfig(this.testOptions)
];
this.config = webpackMerge(webpackConfigs);
// 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;
}
}