feat:增加支持打包时自动生成CNAME

This commit is contained in:
zhangchuanlong
2022-01-25 15:25:29 +08:00
parent 9b4a1d223d
commit f744043734
4 changed files with 26 additions and 5 deletions

View File

@@ -40,17 +40,19 @@ function getConfFiles() {
const result = reg.exec(script)
if (result) {
const mode = result[1]
return ['.env', `.env.${mode}`]
return ['.env', '.env.local', `.env.${mode}`]
}
return ['.env', '.env.production']
return ['.env', '.env.local', '.env.production']
}
export function getEnvConfig(match = 'VITE_APP_GLOB_', confFiles = getConfFiles()) {
let envConfig = {}
confFiles.forEach((item) => {
try {
const env = dotenv.parse(fs.readFileSync(path.resolve(process.cwd(), item)))
envConfig = { ...envConfig, ...env }
if (fs.existsSync(path.resolve(process.cwd(), item))) {
const env = dotenv.parse(fs.readFileSync(path.resolve(process.cwd(), item)))
envConfig = { ...envConfig, ...env }
}
} catch (e) {
console.error(`Error in parsing ${item}`, e)
}