fix: 恢复前端环境配置并修复运行时注入
This commit is contained in:
parent
506456b01b
commit
7638250c70
10
.gitignore
vendored
10
.gitignore
vendored
@ -23,15 +23,11 @@ package-lock.json
|
|||||||
.VSCodeCounter
|
.VSCodeCounter
|
||||||
**/backend-mock/data
|
**/backend-mock/data
|
||||||
|
|
||||||
# local env files
|
# local env override files
|
||||||
.env
|
|
||||||
.env.*
|
|
||||||
apps/*/.env
|
|
||||||
apps/*/.env.*
|
|
||||||
!.env.example
|
|
||||||
!apps/*/.env.example
|
|
||||||
.env.local
|
.env.local
|
||||||
.env.*.local
|
.env.*.local
|
||||||
|
apps/*/.env.local
|
||||||
|
apps/*/.env.*.local
|
||||||
.eslintcache
|
.eslintcache
|
||||||
|
|
||||||
logs
|
logs
|
||||||
|
|||||||
8
apps/web-antdv-next/.env
Normal file
8
apps/web-antdv-next/.env
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 应用标题
|
||||||
|
VITE_APP_TITLE=Vben Admin Antdv Next
|
||||||
|
|
||||||
|
# 应用命名空间,用于缓存、store等功能的前缀,确保隔离
|
||||||
|
VITE_APP_NAMESPACE=vben-web-antdv-next
|
||||||
|
|
||||||
|
# 对store进行加密的密钥,在将store持久化到localStorage时会使用该密钥进行加密
|
||||||
|
VITE_APP_STORE_SECURE_KEY=kwitsukasa
|
||||||
7
apps/web-antdv-next/.env.analyze
Normal file
7
apps/web-antdv-next/.env.analyze
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# public path
|
||||||
|
VITE_BASE=/
|
||||||
|
|
||||||
|
# Basic interface address SPA
|
||||||
|
VITE_GLOB_API_URL=/api
|
||||||
|
|
||||||
|
VITE_VISUALIZER=true
|
||||||
17
apps/web-antdv-next/.env.development
Normal file
17
apps/web-antdv-next/.env.development
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# 端口号
|
||||||
|
VITE_PORT=5999
|
||||||
|
|
||||||
|
VITE_BASE=/
|
||||||
|
VITE_ROUTER_HISTORY=hash
|
||||||
|
|
||||||
|
# 接口地址
|
||||||
|
VITE_GLOB_API_URL=/api
|
||||||
|
|
||||||
|
# 是否开启 Nitro Mock服务,true 为开启,false 为关闭
|
||||||
|
VITE_NITRO_MOCK=false
|
||||||
|
|
||||||
|
# 是否打开 devtools,true 为打开,false 为关闭
|
||||||
|
VITE_DEVTOOLS=false
|
||||||
|
|
||||||
|
# 是否注入全局loading
|
||||||
|
VITE_INJECT_APP_LOADING=true
|
||||||
19
apps/web-antdv-next/.env.production
Normal file
19
apps/web-antdv-next/.env.production
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
VITE_BASE=/
|
||||||
|
|
||||||
|
# 接口地址
|
||||||
|
VITE_GLOB_API_URL=/api
|
||||||
|
|
||||||
|
# 是否开启压缩,可以设置为 none, brotli, gzip
|
||||||
|
VITE_COMPRESS=none
|
||||||
|
|
||||||
|
# 是否开启 PWA
|
||||||
|
VITE_PWA=false
|
||||||
|
|
||||||
|
# vue-router 的模式
|
||||||
|
VITE_ROUTER_HISTORY=hash
|
||||||
|
|
||||||
|
# 是否注入全局loading
|
||||||
|
VITE_INJECT_APP_LOADING=true
|
||||||
|
|
||||||
|
# 打包后是否生成dist.zip
|
||||||
|
VITE_ARCHIVER=true
|
||||||
@ -39,6 +39,7 @@ async function loadEnv<T = Record<string, string>>(
|
|||||||
confFiles = getConfFiles(),
|
confFiles = getConfFiles(),
|
||||||
) {
|
) {
|
||||||
let envConfig = {};
|
let envConfig = {};
|
||||||
|
const reg = new RegExp(`^(${match})`);
|
||||||
|
|
||||||
for (const confFile of confFiles) {
|
for (const confFile of confFiles) {
|
||||||
try {
|
try {
|
||||||
@ -54,7 +55,13 @@ async function loadEnv<T = Record<string, string>>(
|
|||||||
console.error(`Error while parsing ${confFile}`, error);
|
console.error(`Error while parsing ${confFile}`, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const reg = new RegExp(`^(${match})`);
|
|
||||||
|
for (const [key, value] of Object.entries(process.env)) {
|
||||||
|
if (reg.test(key) && value !== undefined) {
|
||||||
|
envConfig = { ...envConfig, [key]: value };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Object.keys(envConfig).forEach((key) => {
|
Object.keys(envConfig).forEach((key) => {
|
||||||
if (!reg.test(key)) {
|
if (!reg.test(key)) {
|
||||||
Reflect.deleteProperty(envConfig, key);
|
Reflect.deleteProperty(envConfig, key);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user