From 6fb2728fbc571379d148b7071c07890b8a99527f Mon Sep 17 00:00:00 2001 From: Ian Wehrman Date: Sat, 9 Jan 2016 14:43:02 -0800 Subject: [PATCH] Define process.env.NODE_ENV for React to use production mode in compiled builds --- webpack.config.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index c51cb9fce..8419dc4ef 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -91,9 +91,13 @@ var buildConfigs = languages.map(function (lang) { extensions: ["", ".js", ".jsx", ".json", ".less"] }, plugins: [ - // This passes __PG_DEBUG__ variable to the bundle new webpack.DefinePlugin({ - __PG_DEBUG__: devMode + // This passes __PG_DEBUG__ variable to the bundle + __PG_DEBUG__: devMode, + // React uses this to enable production mode + "process.env": { + NODE_ENV: devMode ? "\"development\"" : "\"production\"" + } }), new WebpackNotifierPlugin({ alwaysNotify: true }) ],