fix bug where undefined environment variables client side were the string 'undefined'

This commit is contained in:
Cassie Tarakajian 2018-01-09 12:40:44 -05:00
parent 2f29d6add1
commit 5738b07515
2 changed files with 8 additions and 8 deletions

View file

@ -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
}
})
],

View file

@ -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({