diff options
author | Sam Wilkins <samwilkins333@gmail.com> | 2020-04-13 00:56:21 -0700 |
---|---|---|
committer | Sam Wilkins <samwilkins333@gmail.com> | 2020-04-13 00:56:21 -0700 |
commit | bf622aa5b5cd9d3256ee8e4f26245b9858cccfba (patch) | |
tree | b4e3c7f8ee9f935cb4edd507e4c6b23015cc1ab3 /webpack.config.js | |
parent | e3a5dc3ce59b1d8f2dde63395505061b304d64c0 (diff) |
final env cleanup
Diffstat (limited to 'webpack.config.js')
-rw-r--r-- | webpack.config.js | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/webpack.config.js b/webpack.config.js index c8ef269d4..6265883fd 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -16,16 +16,23 @@ const plugins = [ new webpack.HotModuleReplacementPlugin(), ]; -const env = require('dotenv').config().parsed; -if (env) { - plugins.push(new webpack.DefinePlugin(Object.keys(env).reduce((prev, next) => { - if (next.startsWith("DASH_")) { - prev[`process.env.${next.replace("DASH_", "")}`] = JSON.stringify(env[next]); - } - return prev; - }, {}))); +const dotenv = require('dotenv'); + +function transferEnvironmentVariables() { + const prefix = "_CLIENT_"; + const env = dotenv.config().parsed; + if (env) { + plugins.push(new webpack.DefinePlugin(Object.keys(env).reduce((mapping, envKey) => { + if (envKey.startsWith(prefix)) { + mapping[`process.env.${envKey.replace(prefix, "")}`] = JSON.stringify(env[envKey]); + } + return mapping; + }, {}))); + } } +transferEnvironmentVariables(); + module.exports = { mode: 'development', entry: { |