From d2f0668323b087fbc8dc4cbcb54b176e2d4d06b1 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Fri, 20 Oct 2023 10:58:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9quasar=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EnvParse.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/EnvParse.js b/EnvParse.js index 2925aa1..52e047f 100644 --- a/EnvParse.js +++ b/EnvParse.js @@ -1,12 +1,19 @@ - -const DotEnv = require('dotenv') +const DotEnv = require('dotenv'); module.exports = function () { let script = process.env.npm_lifecycle_script; - script = script.substring(script.indexOf("NODE_ENV=") + "NODE_ENV=".length); - let name = script.substring(0,script.indexOf("&")) + 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 -} + name = '.env.' + name; + let parsedEnv = DotEnv.config({ path: name }).parsed; + return parsedEnv; +};