@@ -4,7 +4,7 @@ import * as webpack from 'webpack';
4
4
5
5
import { CliConfig } from '../config' ;
6
6
import { WebpackTestOptions } from '../webpack-test-config' ;
7
- import { KarmaWebpackEmitlessError } from '../../plugins/karma-webpack-emitless-error' ;
7
+
8
8
9
9
/**
10
10
* Enumerate loaders and their dependencies from this file to let the dependency validator
@@ -20,7 +20,9 @@ export function getTestConfig(testConfig: WebpackTestOptions) {
20
20
const configPath = CliConfig . configFilePath ( ) ;
21
21
const projectRoot = path . dirname ( configPath ) ;
22
22
const appConfig = CliConfig . fromProject ( ) . config . apps [ 0 ] ;
23
+ const nodeModules = path . resolve ( projectRoot , 'node_modules' ) ;
23
24
const extraRules : any [ ] = [ ] ;
25
+ const extraPlugins : any [ ] = [ ] ;
24
26
25
27
if ( testConfig . codeCoverage && CliConfig . fromProject ( ) ) {
26
28
const codeCoverageExclude = CliConfig . fromProject ( ) . get ( 'test.codeCoverage.exclude' ) ;
@@ -38,7 +40,6 @@ export function getTestConfig(testConfig: WebpackTestOptions) {
38
40
} ) ;
39
41
}
40
42
41
-
42
43
extraRules . push ( {
43
44
test : / \. ( j s | t s ) $ / , loader : 'istanbul-instrumenter-loader' ,
44
45
enforce : 'post' ,
@@ -49,17 +50,21 @@ export function getTestConfig(testConfig: WebpackTestOptions) {
49
50
return {
50
51
devtool : testConfig . sourcemaps ? 'inline-source-map' : 'eval' ,
51
52
entry : {
52
- test : path . resolve ( projectRoot , appConfig . root , appConfig . test )
53
+ main : path . resolve ( projectRoot , appConfig . root , appConfig . test )
53
54
} ,
54
55
module : {
55
56
rules : [ ] . concat ( extraRules )
56
57
} ,
57
58
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'
61
62
} ) ,
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 )
64
69
} ;
65
70
}
0 commit comments