From 60f4d6750b73fe6b782bb5d498cc69d74ae0cfa1 Mon Sep 17 00:00:00 2001 From: Marshall Quander <marshall@quander.me> Date: Mon, 30 Jul 2018 13:31:26 -0700 Subject: [PATCH] Fiddle with build environment variable loading --- scripts/default.env => .env.defaults | 0 package.json | 1 - scripts/hab-build-and-push.sh | 3 --- scripts/postinstall.js | 9 --------- webpack.config.js | 6 ++++-- 5 files changed, 4 insertions(+), 15 deletions(-) rename scripts/default.env => .env.defaults (100%) delete mode 100644 scripts/postinstall.js diff --git a/scripts/default.env b/.env.defaults similarity index 100% rename from scripts/default.env rename to .env.defaults diff --git a/package.json b/package.json index 631190d49..5d8c7f777 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,6 @@ "url": "https://github.com/mozilla/hubs/issues" }, "scripts": { - "postinstall": "node ./scripts/postinstall.js", "start": "webpack-dev-server --mode=development", "build": "rimraf ./dist && webpack --mode=production", "doc": "node ./scripts/doc/build.js", diff --git a/scripts/hab-build-and-push.sh b/scripts/hab-build-and-push.sh index bfe60faff..48693732a 100755 --- a/scripts/hab-build-and-push.sh +++ b/scripts/hab-build-and-push.sh @@ -23,9 +23,6 @@ rm /usr/bin/env ln -s "$(hab pkg path core/coreutils)/bin/env" /usr/bin/env hab pkg install -b core/coreutils core/bash core/node core/git core/aws-cli -# todo: consider more elegant ways to accomplish this -cp scripts/default.env .env - npm ci --verbose --no-progress npm run build mkdir dist/pages diff --git a/scripts/postinstall.js b/scripts/postinstall.js deleted file mode 100644 index 4d88d1a26..000000000 --- a/scripts/postinstall.js +++ /dev/null @@ -1,9 +0,0 @@ -const fs = require("fs"); -const path = require("path"); - -const src = path.join(__dirname, "default.env"); -const dst = path.join(__dirname, "..", ".env"); - -if (!fs.existsSync()) { - fs.copyFileSync(src, dst); -} diff --git a/webpack.config.js b/webpack.config.js index ddbec2c9b..126247f03 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,5 +1,7 @@ -// Variables in .env will be added to process.env -require("dotenv").config(); +// Variables in .env and .env.defaults will be added to process.env +const dotenv = require("dotenv"); +dotenv.config({ path: ".env" }); +dotenv.config({ path: ".env.defaults" }); const fs = require("fs"); const path = require("path"); -- GitLab