@@ -90,26 +90,46 @@ module.exports = function (options) {
90
90
module : {
91
91
92
92
rules : [
93
+
93
94
/*
94
- * Typescript loader support for .ts and Angular 2 async routes via .async.ts
95
- * Replace templateUrl and stylesUrl with require()
95
+ * Typescript loader support for .ts
96
+ *
97
+ * Component Template/Style integration using `angular2-template-loader`
98
+ * Angular 2 lazy loading (async routes) via `ng-router-loader`
99
+ *
100
+ * `ng-router-loader` expects vanilla JavaScript code, not TypeScript code. This is why the
101
+ * order of the loader matter.
96
102
*
97
103
* See: https://github.com/s-panferov/awesome-typescript-loader
98
104
* See: https://github.com/TheLarkInn/angular2-template-loader
105
+ * See: https://github.com/shlomiassaf/ng-router-loader
99
106
*/
100
107
{
101
108
test : / \. t s $ / ,
102
109
use : [
103
- '@angularclass/hmr-loader?pretty=' + ! isProd + '&prod=' + isProd ,
104
- 'awesome-typescript-loader?{configFileName: "tsconfig.webpack.json"}' ,
105
- 'angular2-template-loader' ,
106
110
{
111
+ loader : '@angularclass/hmr-loader' ,
112
+ options : {
113
+ pretty : ! isProd ,
114
+ prod : isProd
115
+ }
116
+ } ,
117
+ { // MAKE SURE TO CHAIN VANILLA JS CODE, I.E. TS COMPILATION OUTPUT.
107
118
loader : 'ng-router-loader' ,
108
119
options : {
109
- loader : 'async-system ' ,
120
+ loader : 'async-import ' ,
110
121
genDir : 'compiled' ,
111
122
aot : AOT
112
123
}
124
+ } ,
125
+ {
126
+ loader : 'awesome-typescript-loader' ,
127
+ options : {
128
+ configFileName : 'tsconfig.webpack.json'
129
+ }
130
+ } ,
131
+ {
132
+ loader : 'angular2-template-loader'
113
133
}
114
134
] ,
115
135
exclude : [ / \. ( s p e c | e 2 e ) \. t s $ / ]
@@ -220,7 +240,7 @@ module.exports = function (options) {
220
240
new CommonsChunkPlugin ( {
221
241
name : 'vendor' ,
222
242
chunks : [ 'main' ] ,
223
- minChunks : module => / n o d e _ m o d u l e s \/ / . test ( module . resource )
243
+ minChunks : module => / n o d e _ m o d u l e s / . test ( module . resource )
224
244
} ) ,
225
245
// Specify the correct order the scripts will be injected in
226
246
new CommonsChunkPlugin ( {
0 commit comments