@@ -13,6 +13,7 @@ const additionalPlugins = [
1313] ;
1414
1515module . exports = ( env , argv ) => {
16+ let nodeEnv = argv . mode ;
1617 if ( process . env . CI_PACKAGE ) {
1718 // Don't run minification for CI builds (this is only set for runs on develop)
1819 // We override this via environment variable to avoid duplicating the scripts
@@ -24,14 +25,7 @@ module.exports = (env, argv) => {
2425 // when working on the app but adds significant runtime overhead
2526 // We want to use the React production build but not compile the whole
2627 // application to productions standards
27- additionalPlugins . concat ( [
28- new webpack . EnvironmentPlugin ( {
29- "NODE_ENV" : "production" ,
30- } ) ,
31- new webpack . DefinePlugin ( {
32- "process.env.NODE_ENV" : "production" ,
33- } ) ,
34- ] ) ;
28+ nodeEnv = "production" ;
3529 }
3630
3731 const development = { } ;
@@ -94,6 +88,10 @@ module.exports = (env, argv) => {
9488 // we use a CSS optimizer too and need to manage it ourselves.
9589 minimize : argv . mode === 'production' ,
9690 minimizer : argv . mode === 'production' ? [ new TerserPlugin ( { } ) , new OptimizeCSSAssetsPlugin ( { } ) ] : [ ] ,
91+
92+ // Set the value of `process.env.NODE_ENV` for libraries like React
93+ // See also https://v4.webpack.js.org/configuration/optimization/#optimizationnodeenv
94+ nodeEnv,
9795 } ,
9896
9997 resolve : {
0 commit comments