aboutsummaryrefslogtreecommitdiff
path: root/webpack.config.js
diff options
context:
space:
mode:
Diffstat (limited to 'webpack.config.js')
-rw-r--r--webpack.config.js27
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',