@@ -108,6 +108,7 @@ const developmentConfig = {
108108
109109// special config for production
110110const productionConfig = {
111+ bail : true , // Stop the build on errors
111112 plugins : [
112113 new webpack . DefinePlugin ( {
113114 'process.env.NODE_ENV' : JSON . stringify ( 'production' )
@@ -116,16 +117,39 @@ const productionConfig = {
116117 optimization : {
117118 minimize : true ,
118119 minimizer : [ new TerserPlugin ( ) ]
119- }
120+ } ,
121+ }
122+
123+ const ignorePerformanceWarnings = {
124+ performance : {
125+ hints : false // Suppress performance warnings in prod
126+ } ,
127+ ignoreWarnings : [ // ignore performance issues
128+ { message : / p e r f o r m a n c e r e c o m m e n d a t i o n s / } ,
129+ { message : / a s s e t s i z e l i m i t / } ,
130+ { message : / e n t r y p o i n t s i z e l i m i t / }
131+ ]
120132}
121133
122134// combine config depending on the provided --mode command line option
123135module . exports = ( env , argv ) => {
124136 return configList . map ( config => {
125- if ( argv . mode === 'development' ) {
126- return merge ( config , baseConfig , developmentConfig )
127- } else {
128- return merge ( config , baseConfig , productionConfig )
137+ switch ( argv . mode ) {
138+
139+ case 'development' :
140+ // used for build and watch
141+ return merge ( config , baseConfig , developmentConfig )
142+
143+ case 'production' :
144+ if ( env && env [ 'ignore-perf' ] ) {
145+ // build:dist will ignore performance warnings but fails on other warnings
146+ return merge ( config , baseConfig , productionConfig , ignorePerformanceWarnings )
147+ }
148+ // build:prod
149+ return merge ( config , baseConfig , productionConfig )
150+
151+ default :
152+ throw new Error ( 'Invalid mode' )
129153 }
130154 } )
131155}
0 commit comments