@@ -13,44 +13,22 @@ export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) {
13
13
let outputPath : string = path . resolve ( projectRoot , outputDir ) ;
14
14
const lazyModules = findLazyModules ( path . resolve ( projectRoot , sourceDir ) ) ;
15
15
16
- const entries = Object . assign ( {
17
- main : [ path . join ( sourceRoot , 'main.ts' ) ] ,
18
- polyfills : path . join ( sourceRoot , 'polyfills.ts' )
19
- } , lazyModules ) ;
20
-
21
-
22
16
return {
23
17
devtool : 'source-map' ,
24
18
resolve : {
25
19
extensions : [ '' , '.ts' , '.js' ] ,
26
20
root : path . resolve ( projectRoot , `./${ sourceDir } ` )
27
21
} ,
28
22
context : path . resolve ( __dirname , './' ) ,
29
- entry : entries ,
23
+ entry : {
24
+ main : [ path . join ( sourceRoot , 'main.ts' ) ] ,
25
+ polyfills : path . join ( sourceRoot , 'polyfills.ts' )
26
+ } ,
30
27
output : {
31
28
path : outputPath ,
32
29
filename : '[name].bundle.js'
33
30
} ,
34
31
module : {
35
- preLoaders : [
36
- {
37
- test : / \. j s $ / ,
38
- loader : 'source-map-loader' ,
39
- exclude : [
40
- path . resolve ( projectRoot , 'node_modules/rxjs' ) ,
41
- path . resolve ( projectRoot , 'node_modules/@angular' ) ,
42
- ]
43
- } ,
44
- {
45
- test : / ( s y s t e m j s _ c o m p o n e n t _ r e s o l v e r | s y s t e m _ j s _ n g _ m o d u l e _ f a c t o r y _ l o a d e r ) \. j s $ / ,
46
- loader : 'string-replace-loader' ,
47
- query : {
48
- search : '(lang_1(.*[\\n\\r]+\\s*\\.|\\.))?(global(.*[\\n\\r]+\\s*\\.|\\.))?(System|SystemJS)(.*[\\n\\r]+\\s*\\.|\\.)import\\(' ,
49
- replace : 'System.import("" + ' ,
50
- flags : 'g'
51
- }
52
- } ,
53
- ] ,
54
32
loaders : [
55
33
{
56
34
test : / \. t s $ / ,
@@ -77,13 +55,14 @@ export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) {
77
55
]
78
56
} ,
79
57
plugins : [
58
+ new webpack . ContextReplacementPlugin ( / .* / , sourceRoot , lazyModules ) ,
80
59
new atl . ForkCheckerPlugin ( ) ,
81
60
new HtmlWebpackPlugin ( {
82
61
template : path . resolve ( projectRoot , `./${ sourceDir } /index.html` ) ,
83
62
chunksSortMode : 'dependency'
84
63
} ) ,
85
64
new webpack . optimize . CommonsChunkPlugin ( {
86
- name : 'polyfills'
65
+ name : [ 'polyfills' ]
87
66
} ) ,
88
67
new webpack . optimize . CommonsChunkPlugin ( {
89
68
minChunks : Infinity ,
0 commit comments