From 7d40cdff2e0948eafb90178192ae00f312a6ac60 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Sun, 1 Apr 2018 17:22:14 -0700 Subject: [PATCH] Include environment variables from config --- lib/build.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/build.js b/lib/build.js index f1130872..fdbb18e9 100644 --- a/lib/build.js +++ b/lib/build.js @@ -22,6 +22,13 @@ function webpackConfig(dir, additionalConfig) { ]; } + // Include environment variables from config if available + var defineEnv = {}; + var envConfig = config.build.environment || config.build.Environment || {}; + Object.keys(envConfig).forEach((key) => { + defineEnv["process.env." + key] = JSON.stringify(envConfig[key]); + }); + var webpackConfig = { module: { rules: [ @@ -38,7 +45,10 @@ function webpackConfig(dir, additionalConfig) { context: path.join(process.cwd(), dir), entry: {}, target: "node", - plugins: [new webpack.IgnorePlugin(/vertx/)], + plugins: [ + new webpack.IgnorePlugin(/vertx/), + new webpack.DefinePlugin(defineEnv), + ], output: { path: path.join( process.cwd(),