|
|
|
|
/*
|
|
|
|
|
* @Author: ch
|
|
|
|
|
* @Date: 2022-05-05 14:40:00
|
|
|
|
|
* @LastEditors: ch cwl_ch@163.com
|
|
|
|
|
* @LastEditTime: 2022-08-03 16:47:17
|
|
|
|
|
* @Description:
|
|
|
|
|
* 开发时如果环境变量换了,可以不用重启服务,直接运行node env.config.js即可
|
|
|
|
|
*/
|
|
|
|
|
const fs = require("fs");
|
|
|
|
|
const path = require("path");
|
|
|
|
|
|
|
|
|
|
const envConfig = {
|
|
|
|
|
dev: {
|
|
|
|
|
base_url: "https://k8s-horse-gateway.mashibing.cn",
|
|
|
|
|
imUrl: "wss://k8s-horse-gateway.mashibing.cn",
|
|
|
|
|
},
|
|
|
|
|
test: {
|
|
|
|
|
base_url: "https://k8s-horse-gateway.mashibing.cn",
|
|
|
|
|
imUrl: "wss://k8s-horse-gateway.mashibing.cn",
|
|
|
|
|
},
|
|
|
|
|
beta: {
|
|
|
|
|
base_url: "https://you-gateway.mashibing.com",
|
|
|
|
|
imUrl: "wss://you-gateway.mashibing.com",
|
|
|
|
|
},
|
|
|
|
|
prod: {
|
|
|
|
|
base_url: "https://you-gateway.mashibing.com",
|
|
|
|
|
imUrl: "wss://you-gateway.mashibing.com",
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
let curEnvConfig = null;
|
|
|
|
|
const argv = global.process.argv;
|
|
|
|
|
for (key in envConfig) {
|
|
|
|
|
if (argv.includes(`--ENV:${key}`)) {
|
|
|
|
|
curEnvConfig = envConfig[key];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!curEnvConfig) {
|
|
|
|
|
curEnvConfig = envConfig.dev;
|
|
|
|
|
}
|
|
|
|
|
fs.writeFileSync(
|
|
|
|
|
`${path.resolve(__dirname, "./src/common/plugins/config")}/env.js`,
|
|
|
|
|
`const ENV = ${JSON.stringify(curEnvConfig)}; export default ENV;`
|
|
|
|
|
);
|