-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.env.config.ts
47 lines (44 loc) · 895 Bytes
/
.env.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/** 请求环境配置 */
type ServiceEnv = Record<EnvType, EnvConfig[]>;
/** 环境配置 */
const serviceEnvConfig: ServiceEnv = {
dev: [
{
url: 'https://mock.apifox.cn/m1/3402401-0-default/api/v1',
proxy: '/mock',
},
{
url: 'http://127.0.0.1:8087',
proxy: '/go',
}
],
test: [
{
url: 'http://localhost:8080',
proxy: '/mock',
},
],
prod: [
{
url: 'http://localhost:8080',
proxy: '/mock',
},
],
};
/**
* 获取环境配置
* @param env 环境描述
*/
export const getEnvConfig = (env: ImportMetaEnv): EnvConfig[] => {
const {VITE_ENV_TYPE = 'dev'} = env;
switch (VITE_ENV_TYPE) {
case 'dev':
return serviceEnvConfig.dev;
case 'test':
return serviceEnvConfig.test;
case 'prod':
return serviceEnvConfig.prod;
default:
return serviceEnvConfig.dev;
}
};