Only merge dotenv if .env file exists

This commit is contained in:
2022-08-14 20:01:51 +02:00
parent 91c75198de
commit 5f1de791c0
2 changed files with 7 additions and 6 deletions

View File

@@ -13,11 +13,13 @@ const publicPath = path.resolve(__dirname, "public");
const isProd = process.env.NODE_ENV === "production";
// Merge inn all process.env values that match dotenv keys
Object.keys(process.env).forEach(key => {
if (key in dotenv.parsed) {
dotenv.parsed[key] = process.env[key];
}
});
if (dotenv.parsed) {
Object.keys(process.env).forEach(key => {
if (key in dotenv.parsed) {
dotenv.parsed[key] = process.env[key];
}
});
}
module.exports = {
mode: process.env.NODE_ENV,