Add support for environment variables

This commit is contained in:
Kamran Ahmed
2020-06-21 23:38:38 +04:00
parent bcad685e27
commit 9d2fdfa7cf
4 changed files with 13 additions and 12 deletions

View File

@@ -20,14 +20,20 @@ const { getPathMap } = require("./scripts/path-map");
const loadConfig = (env = 'dev') => {
const configPath = `./config/${env}.json`;
if (!fs.existsSync(configPath)) {
console.log(`Config file not found: ${configPath}`);
process.exit(1);
console.warn(`Config file not found: ${configPath}. Using environment variables only.`);
}
const appConfig = {};
for (let key in process.env) {
if (!key.startsWith('ROADMAP_')) {
continue;
}
appConfig[key.replace('ROADMAP_', '')] = process.env[key];
}
console.log(`Config file found: ${configPath}`);
// @todo stringify the values for webpack - it doesn't understand objects
return require(configPath);
return appConfig;
};
const options = {