@@ -9,12 +9,14 @@ import { StaticAssetPlugin } from '../../plugins/static-asset';
99import { GlobCopyWebpackPlugin } from '../../plugins/glob-copy-webpack-plugin' ;
1010import { WebpackConfigOptions } from '../webpack-config' ;
1111
12+ const UglifyJSPlugin = require ( 'uglifyjs-webpack-plugin' ) ;
13+
1214
1315export const getProdConfig = function ( wco : WebpackConfigOptions ) {
1416 const { projectRoot, buildOptions, appConfig } = wco ;
1517
1618 let extraPlugins : any [ ] = [ ] ;
17- let entryPoints : { [ key : string ] : string [ ] } = { } ;
19+ let entryPoints : { [ key : string ] : string [ ] } = { } ;
1820
1921 if ( appConfig . serviceWorker ) {
2022 const nodeModules = path . resolve ( projectRoot , 'node_modules' ) ;
@@ -66,7 +68,7 @@ export const getProdConfig = function (wco: WebpackConfigOptions) {
6668 extraPlugins . push ( new GlobCopyWebpackPlugin ( {
6769 patterns : [
6870 'ngsw-manifest.json' ,
69- { glob : 'ngsw-manifest.json' , input : path . resolve ( projectRoot , appConfig . root ) , output : '' }
71+ { glob : 'ngsw-manifest.json' , input : path . resolve ( projectRoot , appConfig . root ) , output : '' }
7072 ] ,
7173 globOptions : {
7274 cwd : projectRoot ,
@@ -99,7 +101,7 @@ export const getProdConfig = function (wco: WebpackConfigOptions) {
99101 } ) ) ;
100102 }
101103
102- const uglifyCompressOptions : any = { screw_ie8 : true , warnings : buildOptions . verbose } ;
104+ const uglifyCompressOptions : any = { } ;
103105
104106 if ( buildOptions . buildOptimizer ) {
105107 // This plugin must be before webpack.optimize.UglifyJsPlugin.
@@ -110,21 +112,43 @@ export const getProdConfig = function (wco: WebpackConfigOptions) {
110112 uglifyCompressOptions . passes = 3 ;
111113 }
112114
115+ if ( buildOptions . compilationTarget === 'ES2015' ) {
116+ extraPlugins . push ( new UglifyJSPlugin ( {
117+ sourceMap : buildOptions . sourcemaps ,
118+ uglifyOptions : {
119+ ecma : 6 ,
120+ warnings : buildOptions . verbose ,
121+ ie8 : false ,
122+ mangle : true ,
123+ compress : uglifyCompressOptions ,
124+ output : {
125+ ascii_only : true ,
126+ comments : false
127+ } ,
128+ }
129+ } ) ) ;
130+ } else {
131+ uglifyCompressOptions . screw_ie8 = true ;
132+ uglifyCompressOptions . warnings = buildOptions . verbose ;
133+ extraPlugins . push ( new webpack . optimize . UglifyJsPlugin ( < any > {
134+ mangle : { screw_ie8 : true } ,
135+ compress : uglifyCompressOptions ,
136+ output : { ascii_only : true } ,
137+ sourceMap : buildOptions . sourcemaps ,
138+ comments : false
139+ } ) ) ;
140+
141+ }
142+
113143 return {
114144 entry : entryPoints ,
115- plugins : extraPlugins . concat ( [
145+ plugins : [
116146 new webpack . EnvironmentPlugin ( {
117147 'NODE_ENV' : 'production'
118148 } ) ,
119149 new webpack . HashedModuleIdsPlugin ( ) ,
120150 new webpack . optimize . ModuleConcatenationPlugin ( ) ,
121- new webpack . optimize . UglifyJsPlugin ( < any > {
122- mangle : { screw_ie8 : true } ,
123- compress : uglifyCompressOptions ,
124- output : { ascii_only : true } ,
125- sourceMap : buildOptions . sourcemaps ,
126- comments : false
127- } )
128- ] )
151+ ...extraPlugins
152+ ]
129153 } ;
130154} ;
0 commit comments