You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
482 B
JavaScript
21 lines
482 B
JavaScript
const dotenvExpand = require("dotenv-expand");
|
|
const path = require("path");
|
|
const dotenv = require("dotenv");
|
|
|
|
module.exports = function loadEnv() {
|
|
const mode = process.env.NODE_ENV;
|
|
const basePath = path.resolve(__dirname, `../.env${mode ? `.${mode}` : ``}`);
|
|
|
|
const load = (envPath) => {
|
|
try {
|
|
const env = dotenv.config({
|
|
path: envPath,
|
|
debug: process.env.DEBUG,
|
|
});
|
|
dotenvExpand(env);
|
|
} catch (err) {}
|
|
};
|
|
|
|
load(basePath);
|
|
};
|