@@ -35,17 +35,14 @@ module.exports = function makeWebpackConfig() {
3535 */
3636 if ( isProd ) {
3737 config . devtool = 'source-map' ;
38- }
38+ }
3939 else if ( isTest ) {
4040 config . devtool = 'inline-source-map' ;
4141 }
4242 else {
4343 config . devtool = 'eval-source-map' ;
4444 }
4545
46- // add debug messages
47- config . debug = ! isProd || ! isTest ;
48-
4946 /**
5047 * Entry
5148 * Reference: http://webpack.github.io/docs/configuration.html#entry
@@ -72,21 +69,15 @@ module.exports = function makeWebpackConfig() {
7269 * Reference: http://webpack.github.io/docs/configuration.html#resolve
7370 */
7471 config . resolve = {
75- cache : ! isTest ,
76- root : root ( ) ,
7772 // only discover files that have those extensions
78- extensions : [ '' , '.ts' , '.js' , '.json' , '.css' , '.scss' , '.html' ] ,
79- alias : {
80- 'app' : 'src/app' ,
81- 'common' : 'src/common'
82- }
73+ extensions : [ '.ts' , '.js' , '.json' , '.css' , '.scss' , '.html' ] ,
8374 } ;
8475
8576 var atlOptions = '' ;
8677 if ( isTest && ! isTestWatch ) {
8778 // awesome-typescript-loader needs to output inlineSourceMap for code coverage to work with source maps.
8879 atlOptions = 'inlineSourceMap=true&sourceMap=false' ;
89- }
80+ }
9081
9182 /**
9283 * Loaders
@@ -95,8 +86,7 @@ module.exports = function makeWebpackConfig() {
9586 * This handles most of the magic responsible for converting modules
9687 */
9788 config . module = {
98- preLoaders : isTest ? [ ] : [ { test : / \. t s $ / , loader : 'tslint' } ] ,
99- loaders : [
89+ rules : [
10090 // Support for .ts files.
10191 {
10292 test : / \. t s $ / ,
@@ -119,7 +109,7 @@ module.exports = function makeWebpackConfig() {
119109 {
120110 test : / \. c s s $ / ,
121111 exclude : root ( 'src' , 'app' ) ,
122- loader : isTest ? 'null' : ExtractTextPlugin . extract ( 'style' , 'css?sourceMap! postcss' )
112+ loader : isTest ? 'null' : ExtractTextPlugin . extract ( { fallbackLoader : 'style-loader ' , loader : [ 'css' , ' postcss'] } )
123113 } ,
124114 // all css required in src/app files will be merged in js files
125115 { test : / \. c s s $ / , include : root ( 'src' , 'app' ) , loader : 'raw!postcss' } ,
@@ -130,28 +120,37 @@ module.exports = function makeWebpackConfig() {
130120 {
131121 test : / \. s c s s $ / ,
132122 exclude : root ( 'src' , 'app' ) ,
133- loader : isTest ? 'null' : ExtractTextPlugin . extract ( 'style' , 'css?sourceMap! postcss! sass' )
123+ loader : isTest ? 'null' : ExtractTextPlugin . extract ( { fallbackLoader : 'style-loader ' , loader : [ 'css' , ' postcss' , ' sass'] } )
134124 } ,
135125 // all css required in src/app files will be merged in js files
136126 { test : / \. s c s s $ / , exclude : root ( 'src' , 'style' ) , loader : 'raw!postcss!sass' } ,
137127
138128 // support for .html as raw text
139129 // todo: change the loader to something that adds a hash to images
140130 { test : / \. h t m l $ / , loader : 'raw' , exclude : root ( 'src' , 'public' ) }
141- ] ,
142- postLoaders : [ ]
131+ ]
143132 } ;
144133
145134 if ( isTest && ! isTestWatch ) {
146135 // instrument only testing sources with Istanbul, covers ts files
147- config . module . postLoaders . push ( {
136+ config . module . rules . push ( {
148137 test : / \. t s $ / ,
138+ enforce : 'post' ,
149139 include : path . resolve ( 'src' ) ,
150140 loader : 'istanbul-instrumenter-loader' ,
151141 exclude : [ / \. s p e c \. t s $ / , / \. e 2 e \. t s $ / , / n o d e _ m o d u l e s / ]
152142 } ) ;
153143 }
154144
145+ if ( ! isTest || ! isTestWatch ) {
146+ // tslint support
147+ config . module . rules . push ( {
148+ test : / \. t s $ / ,
149+ enforce : 'pre' ,
150+ loader : 'tslint'
151+ } ) ;
152+ }
153+
155154 /**
156155 * Plugins
157156 * Reference: http://webpack.github.io/docs/configuration.html#plugins
@@ -165,14 +164,53 @@ module.exports = function makeWebpackConfig() {
165164 'process.env' : {
166165 ENV : JSON . stringify ( ENV )
167166 }
167+ } ) ,
168+
169+ // Workaround needed for angular 2 angular/angular#11580
170+ new webpack . ContextReplacementPlugin (
171+ // The (\\|\/) piece accounts for path separators in *nix and Windows
172+ / a n g u l a r ( \\ | \/ ) c o r e ( \\ | \/ ) ( e s m ( \\ | \/ ) s r c | s r c ) ( \\ | \/ ) l i n k e r / ,
173+ root ( './src' ) // location of your src
174+ ) ,
175+
176+ // Tslint configuration for webpack 2
177+ new webpack . LoaderOptionsPlugin ( {
178+ options : {
179+ /**
180+ * Apply the tslint loader as pre/postLoader
181+ * Reference: https://github.com/wbuchwalter/tslint-loader
182+ */
183+ tslint : {
184+ emitErrors : false ,
185+ failOnHint : false
186+ } ,
187+ /**
188+ * Sass
189+ * Reference: https://github.com/jtangelder/sass-loader
190+ * Transforms .scss files to .css
191+ */
192+ sassLoader : {
193+ //includePaths: [path.resolve(__dirname, "node_modules/foundation-sites/scss")]
194+ } ,
195+ /**
196+ * PostCSS
197+ * Reference: https://github.com/postcss/autoprefixer-core
198+ * Add vendor prefixes to your css
199+ */
200+ postcss : [
201+ autoprefixer ( {
202+ browsers : [ 'last 2 version' ]
203+ } )
204+ ]
205+ }
168206 } )
169207 ] ;
170208
171209 if ( ! isTest && ! isProd ) {
172210 config . plugins . push ( new DashboardPlugin ( ) ) ;
173211 }
174212
175- if ( ! isTest ) {
213+ if ( ! isTest || ! isTestWatch ) {
176214 config . plugins . push (
177215 new ForkCheckerPlugin ( ) ,
178216
@@ -193,7 +231,7 @@ module.exports = function makeWebpackConfig() {
193231 // Extract css files
194232 // Reference: https://github.com/webpack/extract-text-webpack-plugin
195233 // Disabled when in test mode or not in build mode
196- new ExtractTextPlugin ( 'css/[name].[hash].css' , { disable : ! isProd } )
234+ new ExtractTextPlugin ( { filename : 'css/[name].[hash].css' , disable : ! isProd } )
197235 ) ;
198236 }
199237
@@ -204,13 +242,13 @@ module.exports = function makeWebpackConfig() {
204242 // Only emit files when there are no errors
205243 new webpack . NoErrorsPlugin ( ) ,
206244
207- // Reference: http://webpack.github.io/docs/list-of-plugins.html#dedupeplugin
208- // Dedupe modules in the output
209- new webpack . optimize . DedupePlugin ( ) ,
245+ // // Reference: http://webpack.github.io/docs/list-of-plugins.html#dedupeplugin
246+ // // Dedupe modules in the output
247+ // new webpack.optimize.DedupePlugin(),
210248
211249 // Reference: http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
212250 // Minify all javascript, switch loaders to minimizing mode
213- new webpack . optimize . UglifyJsPlugin ( { mangle : { keep_fnames : true } } ) ,
251+ new webpack . optimize . UglifyJsPlugin ( { sourceMap : true , mangle : { keep_fnames : true } } ) ,
214252
215253 // Copy assets from the public folder
216254 // Reference: https://github.com/kevlened/copy-webpack-plugin
@@ -220,35 +258,6 @@ module.exports = function makeWebpackConfig() {
220258 ) ;
221259 }
222260
223- /**
224- * PostCSS
225- * Reference: https://github.com/postcss/autoprefixer-core
226- * Add vendor prefixes to your css
227- */
228- config . postcss = [
229- autoprefixer ( {
230- browsers : [ 'last 2 version' ]
231- } )
232- ] ;
233-
234- /**
235- * Sass
236- * Reference: https://github.com/jtangelder/sass-loader
237- * Transforms .scss files to .css
238- */
239- config . sassLoader = {
240- //includePaths: [path.resolve(__dirname, "node_modules/foundation-sites/scss")]
241- } ;
242-
243- /**
244- * Apply the tslint loader as pre/postLoader
245- * Reference: https://github.com/wbuchwalter/tslint-loader
246- */
247- config . tslint = {
248- emitErrors : false ,
249- failOnHint : false
250- } ;
251-
252261 /**
253262 * Dev server configuration
254263 * Reference: http://webpack.github.io/docs/configuration.html#devserver
0 commit comments