diff options
author | Sam Wilkins <samwilkins333@gmail.com> | 2020-05-14 01:29:19 -0700 |
---|---|---|
committer | Sam Wilkins <samwilkins333@gmail.com> | 2020-05-14 01:29:19 -0700 |
commit | f9385130fe297088754d4ce46d6c318c8be2121d (patch) | |
tree | 0435585464fb614e6126f59136d64bcb87cb65bd /webpack.config.js | |
parent | 26e94812b02e178ead5d5be7cfe5bf73e92ac875 (diff) |
server side restructure, some documentation to accompany new wiki overview entry
Diffstat (limited to 'webpack.config.js')
-rw-r--r-- | webpack.config.js | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/webpack.config.js b/webpack.config.js index 6265883fd..67d492e1f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -16,22 +16,21 @@ const plugins = [ new webpack.HotModuleReplacementPlugin(), ]; -const dotenv = require('dotenv'); - -function transferEnvironmentVariables() { +(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; - }, {}))); + const { + parsed + } = require('dotenv').config(); + if (!parsed) { + return; } -} - -transferEnvironmentVariables(); + plugins.push(new webpack.DefinePlugin(Object.keys(parsed).reduce((mapping, envKey) => { + if (envKey.startsWith(prefix)) { + mapping[`process.env.${envKey.replace(prefix, "")}`] = JSON.stringify(parsed[envKey]); + } + return mapping; + }, {}))); +})(); module.exports = { mode: 'development', |