From 5738b07515b2c1bfc86aeeeed5f00466c2fb8e6b Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Tue, 9 Jan 2018 12:40:44 -0500 Subject: [PATCH] fix bug where undefined environment variables client side were the string 'undefined' --- webpack.config.dev.js | 8 ++++---- webpack.config.prod.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/webpack.config.dev.js b/webpack.config.dev.js index 67127f20..6322d420 100644 --- a/webpack.config.dev.js +++ b/webpack.config.dev.js @@ -34,15 +34,15 @@ module.exports = { }), new webpack.DefinePlugin({ 'process.env': { - API_URL: '"' + process.env.API_URL + '"', + API_URL: process.env.API_URL ? '"' + process.env.API_URL + '"' : undefined, CLIENT: JSON.stringify(true), FORCE_TO_HTTPS: process.env.FORCE_TO_HTTPS === 'true' ? JSON.stringify(true) : JSON.stringify(false), 'NODE_ENV': JSON.stringify('development'), - 'S3_BUCKET': '"' + process.env.S3_BUCKET + '"', - 'S3_BUCKET_URL_BASE': '"' + process.env.S3_BUCKET_URL_BASE + '"', - 'AWS_REGION': '"' + process.env.AWS_REGION + '"', + 'S3_BUCKET': process.env.S3_BUCKET ? '"' + process.env.S3_BUCKET + '"' : undefined, + 'S3_BUCKET_URL_BASE': process.env.S3_BUCKET_URL_BASE ? '"' + process.env.S3_BUCKET_URL_BASE + '"' : undefined, + 'AWS_REGION': process.env.AWS_REGION ? '"' + process.env.AWS_REGION + '"': undefined } }) ], diff --git a/webpack.config.prod.js b/webpack.config.prod.js index e5f9d037..3972c212 100644 --- a/webpack.config.prod.js +++ b/webpack.config.prod.js @@ -79,11 +79,11 @@ module.exports = { plugins: [ new webpack.DefinePlugin({ 'process.env': { - 'API_URL': '"' + process.env.API_URL + '"', + 'API_URL': process.env.API_URL ? '"' + process.env.API_URL + '"' : undefined, 'NODE_ENV': JSON.stringify('production'), - 'S3_BUCKET': '"' + process.env.S3_BUCKET + '"', - 'S3_BUCKET_URL_BASE': '"' + process.env.S3_BUCKET_URL_BASE + '"', - 'AWS_REGION': '"' + process.env.AWS_REGION + '"' + 'S3_BUCKET': process.env.S3_BUCKET ? '"' + process.env.S3_BUCKET + '"' : undefined, + 'S3_BUCKET_URL_BASE': process.env.S3_BUCKET_URL_BASE ? '"' + process.env.S3_BUCKET_URL_BASE + '"' : undefined, + 'AWS_REGION': process.env.AWS_REGION ? '"' + process.env.AWS_REGION + '"': undefined } }), new webpack.optimize.CommonsChunkPlugin({