@ -33,7 +33,7 @@ module.exports = function(env) {
const isProduction = env && env . production ;
const isTests = env && env . target === 'tests' ;
const isCoverage = env && env . coverage ;
const isJit = env && env . jit ;
const isAot = isProduction ;
const config = {
mode : isProduction ? 'production' : 'development' ,
@ -56,7 +56,7 @@ module.exports = function(env) {
*
* See : https : //webpack.js.org/configuration/resolve/#resolve-extensions
* /
extensions : [ '.js' , '.mjs' , '.t s' , '.css' , '.scss' ] ,
extensions : [ '.ts' , '. js' , '.mjs' , '.css' , '.scss' ] ,
modules : [
root ( 'app' ) ,
root ( 'app' , 'theme' ) ,
@ -181,8 +181,6 @@ module.exports = function(env) {
}
} ;
console . log ( JSON . stringify ( config , null , 2 ) ) ;
if ( ! isTests ) {
/ * *
* The entry point for the bundle . Our Angular app .
@ -258,6 +256,15 @@ module.exports = function(env) {
waitForLinting : isProduction
} )
) ;
config . plugins . push (
new plugins . NgToolsWebpack . AngularCompilerPlugin ( {
entryModule : 'app/app.module#AppModule' ,
sourceMap : ! isProduction ,
skipSourceGeneration : ! isAot ,
tsConfigPath : './tsconfig.json'
} )
) ;
}
if ( isProduction ) {
@ -284,14 +291,8 @@ module.exports = function(env) {
} ;
}
if ( ! isCoverage ) {
config . module . rules . push ( {
test : /\.ts$/ ,
use : [ {
loader : 'awesome-typescript-loader' , options : { useCache : true , useBabel : true }
} ]
} )
} else {
if ( isCoverage ) {
// Do not instrument tests.
config . module . rules . push ( {
test : /\.ts$/ ,
use : [ {
@ -300,7 +301,7 @@ module.exports = function(env) {
include : [ /\.(e2e|spec)\.ts$/ ] ,
} ) ;
// Use instrument loader for all normal build s.
// Use instrument loader for all normal file s.
config . module . rules . push ( {
test : /\.ts$/ ,
use : [ {
@ -310,6 +311,13 @@ module.exports = function(env) {
} ] ,
exclude : [ /\.(e2e|spec)\.ts$/ ]
} ) ;
} else {
config . module . rules . push ( {
test : /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/ ,
use : [ {
loader : plugins . NgToolsWebpack . NgToolsLoader
} ]
} )
}
if ( isProduction ) {
@ -349,23 +357,5 @@ module.exports = function(env) {
} ) ;
}
if ( ! isJit ) {
config . module . rules . push ( {
test : /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/ ,
use : [ {
loader : '@ngtools/webpack'
} ]
} ) ;
config . plugins . push (
new plugins . NgToolsWebpack . AngularCompilerPlugin ( {
entryModule : 'app/app.module#AppModule' ,
sourceMap : ! isProduction ,
skipSourceGeneration : false ,
tsConfigPath : './tsconfig.json'
} )
) ;
}
return config ;
} ;