@@ -4,7 +4,7 @@ import * as webpack from 'webpack';
44
55import { CliConfig } from '../config' ;
66import { WebpackTestOptions } from '../webpack-test-config' ;
7- import { KarmaWebpackEmitlessError } from '../../plugins/karma-webpack-emitless-error' ;
7+
88
99/**
1010 * Enumerate loaders and their dependencies from this file to let the dependency validator
@@ -20,7 +20,9 @@ export function getTestConfig(testConfig: WebpackTestOptions) {
2020 const configPath = CliConfig . configFilePath ( ) ;
2121 const projectRoot = path . dirname ( configPath ) ;
2222 const appConfig = CliConfig . fromProject ( ) . config . apps [ 0 ] ;
23+ const nodeModules = path . resolve ( projectRoot , 'node_modules' ) ;
2324 const extraRules : any [ ] = [ ] ;
25+ const extraPlugins : any [ ] = [ ] ;
2426
2527 if ( testConfig . codeCoverage && CliConfig . fromProject ( ) ) {
2628 const codeCoverageExclude = CliConfig . fromProject ( ) . get ( 'test.codeCoverage.exclude' ) ;
@@ -38,7 +40,6 @@ export function getTestConfig(testConfig: WebpackTestOptions) {
3840 } ) ;
3941 }
4042
41-
4243 extraRules . push ( {
4344 test : / \. ( j s | t s ) $ / , loader : 'istanbul-instrumenter-loader' ,
4445 enforce : 'post' ,
@@ -49,17 +50,21 @@ export function getTestConfig(testConfig: WebpackTestOptions) {
4950 return {
5051 devtool : testConfig . sourcemaps ? 'inline-source-map' : 'eval' ,
5152 entry : {
52- test : path . resolve ( projectRoot , appConfig . root , appConfig . test )
53+ main : path . resolve ( projectRoot , appConfig . root , appConfig . test )
5354 } ,
5455 module : {
5556 rules : [ ] . concat ( extraRules )
5657 } ,
5758 plugins : [
58- new webpack . SourceMapDevToolPlugin ( {
59- filename : null , // if no value is provided the sourcemap is inlined
60- test : / \. ( t s | j s ) ( $ | \? ) / i // process .js and .ts files only
59+ new webpack . optimize . CommonsChunkPlugin ( {
60+ minChunks : Infinity ,
61+ name : 'inline'
6162 } ) ,
62- new KarmaWebpackEmitlessError ( )
63- ]
63+ new webpack . optimize . CommonsChunkPlugin ( {
64+ name : 'vendor' ,
65+ chunks : [ 'main' ] ,
66+ minChunks : ( module : any ) => module . resource && module . resource . startsWith ( nodeModules )
67+ } )
68+ ] . concat ( extraPlugins )
6469 } ;
6570}
0 commit comments