New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
怎么配置测试环境,生产环境? #1636
Comments
Translation of this issue: How to configure the test environment and production environment?For example, the request address of my test environment is The request address of the production environment is Is process.env specified via build? |
问题已解决,我现在是这样做的,不知道有没有更好的选择
在webpackrc.js文件中添加define
然后添加一个env.js来判断
|
这么做挺好,roadhog 里只有 process.env.NODE_ENV,且只有 development 和 production,其他环境通过额外的环境变量实现。 |
antd pro2.0怎么配置呢?我没有找到webpackrc.js这个文件 |
请问有完整的配置文件吗?新手正在爬坑中 |
antd小白,参考(https://www.jianshu.com/p/d3b7d815ebb1) ps:sysConfig的东西写在defaultSettings.js里也不错 |
@shadiniao 能否分享一下 websocket proxy的配置方式 |
非常重要: 新版的 Antd Pro 不用 roadhog 了,webpack 的配置都移到了 config/config.js,在
中定义的变量,可以在 src 下的任何 js 中直接使用,像这样 |
@ritingliudd01 谢谢,已经解决 |
区分开发环境变量,mark |
package scripts中用UMI_ENV: "start:sit": "UMI_ENV=sit umi dev", 配置文件用具体环境的后缀名来区分,然后利用已集成的DefinePlugin将NodeEnv转化为JS环境,UMI会自动覆盖: // config/config.ts:
export default {
// ........
define: {
API_SERVER: "https://xxx.xxx.com", // 接口服务器地址
},
// .........
};
// config/config.sit.ts:
export default {
define: {
API_SERVER: "https://xxx.xxx.com", // 接口服务器地址
}
};
// config.sit.ts配置信息会自动覆盖config.ts内的信息,注意是覆盖,不是替换,这其实是UMI提供的特性,开发者应该充分利用UMI已提供的特性来解决多环境问题。 这样才是多环境最优的处理方式。 |
赞同,参阅了 https://umijs.org/zh/guide/config.html#umi-env 配置了不同的 config.[env].js |
还有更优雅的方式吗? |
我感觉配置环境这一方面,飞冰做的不错 |
现在是v5 我还是不知道怎么配置,只要配置了define 接口就会自动变成这个地址吗 |
确实,这是最优雅的配置方式了,但是我配置后打包后始终取的prod的配置,test或者pre都无效=。= |
比如我测试环境的请求地址是
https://192.168.1.1
wss://192.168.1.1
生产环境的请求地址是
https://www.xxx.com
wss://www.xxx.com
是通过build指定process.env吗?
还是设置proxy, websocket的proxy怎么设置
The text was updated successfully, but these errors were encountered: