vue-pure-admin2/build/index.ts

32 lines
831 B
TypeScript
Raw Normal View History

/** 处理环境变量 */
const warpperEnv = (envConf: Recordable): ViteEnv => {
2022-11-17 18:12:03 +08:00
/** 此处为默认值 */
2021-12-04 01:16:50 +08:00
const ret: ViteEnv = {
VITE_PORT: 8848,
VITE_PUBLIC_PATH: "",
VITE_ROUTER_HISTORY: "",
VITE_CDN: false,
VITE_HIDE_HOME: "false",
VITE_COMPRESSION: "none"
2021-12-04 01:16:50 +08:00
};
for (const envName of Object.keys(envConf)) {
let realName = envConf[envName].replace(/\\n/g, "\n");
2021-07-20 17:16:42 +08:00
realName =
realName === "true" ? true : realName === "false" ? false : realName;
2021-07-20 17:16:42 +08:00
if (envName === "VITE_PORT") {
2021-03-01 15:26:05 +08:00
realName = Number(realName);
}
ret[envName] = realName;
if (typeof realName === "string") {
process.env[envName] = realName;
} else if (typeof realName === "object") {
process.env[envName] = JSON.stringify(realName);
}
2021-03-01 15:26:05 +08:00
}
return ret;
};
2021-12-04 01:16:50 +08:00
2022-12-19 11:58:49 +08:00
export { warpperEnv };