File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,6 +103,10 @@ class Config {
103103 return this . utils . normalizePublicPath ( publicPath ) ;
104104 }
105105
106+ get devtool ( ) {
107+ return this . webpackConfig . devtool ;
108+ }
109+
106110 get host ( ) {
107111 let host = '' ;
108112 const config = this . config ;
Original file line number Diff line number Diff line change @@ -65,26 +65,30 @@ module.exports = class WebpackOptimize {
6565 delete this . optimization . minimizer ;
6666 }
6767 // compatible old config
68- const { plugins = { } } = this . ctx . config ;
69- if ( this . ctx . prod && ! this . optimization . minimizer && this . ctx . utils . isObject ( plugins . uglifyJs ) ) {
70- const args = plugins . uglifyJs . args || plugins . uglifyJs ;
71- const options = this . ctx . merge ( {
72- cache : true ,
73- parallel : 2 ,
74- sourceMap : false ,
75- uglifyOptions : {
76- warnings : false ,
77- compress : {
78- dead_code : true ,
79- drop_console : true ,
80- drop_debugger : true
81- } ,
82- output : {
83- comments : false
68+ if ( this . ctx . prod && ! this . optimization . minimizer ) {
69+ const uglifyJs = this . ctx . getConfigPlugin ( 'uglifyJs' ) ;
70+ if ( uglifyJs ) {
71+ const args = this . ctx . utils . isObject ( uglifyJs ) ? uglifyJs . args || uglifyJs : { } ;
72+ const options = this . ctx . merge ( {
73+ cache : true ,
74+ parallel : 4 ,
75+ sourceMap : ! ! this . ctx . devtool ,
76+ uglifyOptions : {
77+ ie8 : false ,
78+ warnings : false ,
79+ compress : {
80+ dead_code : true ,
81+ drop_console : true ,
82+ drop_debugger : true
83+ } ,
84+ output : {
85+ comments : false
86+ }
8487 }
85- }
86- } , args ) ;
87- this . optimization . minimizer = [ new UglifyJsPlugin ( options ) ] ;
88+ } , args ) ;
89+ this . optimization . minimize = false ;
90+ this . optimization . minimizer = [ new UglifyJsPlugin ( options ) ] ;
91+ }
8892 }
8993 return this . optimization ;
9094 }
Original file line number Diff line number Diff line change @@ -6,9 +6,10 @@ module.exports = {
66 getConfigPlugin ( label ) {
77 const plugins = this . config . plugins || { } ;
88 if ( Array . isArray ( plugins ) ) {
9- return plugins . find ( plugin => {
10- return plugin [ label ] || { } ;
9+ const plugin = plugins . find ( item => {
10+ return item . hasOwnProperty ( label ) ;
1111 } ) ;
12+ return plugin && plugin [ label ] || { } ;
1213 }
1314 return plugins [ label ] || { } ;
1415 } ,
You can’t perform that action at this time.
0 commit comments