Skip to content

Commit

Permalink
Merge pull request #22 from kchung/env-variables
Browse files Browse the repository at this point in the history
Include environment variables from config
  • Loading branch information
biilmann authored Apr 3, 2018
2 parents 60bbe7a + ce6cd0e commit 63a7888
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ function webpackConfig(dir, additionalConfig) {
if (dirPath === functionsPath) {
throw new Error("Function source and publish folder should be in different locations");
}


// 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: [
Expand All @@ -46,7 +53,10 @@ function webpackConfig(dir, additionalConfig) {
context: dirPath,
entry: {},
target: "node",
plugins: [new webpack.IgnorePlugin(/vertx/)],
plugins: [
new webpack.IgnorePlugin(/vertx/),
new webpack.DefinePlugin(defineEnv),
],
output: {
path: functionsPath,
filename: "[name].js",
Expand Down

0 comments on commit 63a7888

Please sign in to comment.