From d1756436e83dc4e47ad278b2e8d9e2b5a956e1e4 Mon Sep 17 00:00:00 2001 From: hugh-obrien Date: Fri, 11 May 2018 15:34:22 +0100 Subject: [PATCH] compile react in production mode --- services/web/Jenkinsfile | 2 +- services/web/webpack.config.js | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/services/web/Jenkinsfile b/services/web/Jenkinsfile index 7953aa0dbc..7b44d70315 100644 --- a/services/web/Jenkinsfile +++ b/services/web/Jenkinsfile @@ -101,7 +101,7 @@ pipeline { } } steps { - sh 'make minify' + sh 'WEBPACK_ENV=production make minify' } } diff --git a/services/web/webpack.config.js b/services/web/webpack.config.js index da0dc8257e..95f3fe5f9e 100644 --- a/services/web/webpack.config.js +++ b/services/web/webpack.config.js @@ -1,7 +1,9 @@ const fs = require('fs') const path = require('path') +const webpack = require('webpack') const MODULES_PATH = path.join(__dirname, '/modules') +const webpackENV = process.env.WEBPACK_ENV || 'development' // Generate a hash of entry points, including modules const entryPoints = {} @@ -63,7 +65,16 @@ module.exports = { }] }, - // TODO - // plugins: {} + plugins: [ + new webpack.DefinePlugin({ + // Swaps out checks for NODE_ENV with the env. This is used by various + // libs to enable dev-only features. These checks then become something + // like `if ('production' == 'production')`. Minification will then strip + // the dev-only code from the bundle + 'process.env': { + NODE_ENV: JSON.stringify(webpackENV) + }, + }) + ] }