20 lines
532 B
JavaScript
20 lines
532 B
JavaScript
const DotEnv = require('dotenv');
|
|
|
|
module.exports = function () {
|
|
let script = process.env.npm_lifecycle_script;
|
|
let name = 'dev';
|
|
if (script) {
|
|
// quasar启动没有这个
|
|
script = script.substring(script.indexOf('NODE_ENV=') + 'NODE_ENV='.length);
|
|
name = script.substring(0, script.indexOf('&'));
|
|
} else {
|
|
if (process.env.NODE_ENV == 'production') {
|
|
name = 'prod';
|
|
}
|
|
}
|
|
console.log(name);
|
|
name = '.env.' + name;
|
|
let parsedEnv = DotEnv.config({ path: name }).parsed;
|
|
return parsedEnv;
|
|
};
|