【发布时间】:2020-02-26 05:11:42
【问题描述】:
使用带有"react-scripts": "3.3.1" 的 CRA 构建了一个应用程序,但是我在构建模式方面遇到了问题,例如在 Vue-CLI 中我可以这样做:
npm run build -- --mode staging
// any ENV name i want
但在 CRA 中,有:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
我尝试过类似的方法:
yarn build --mode staging
但它使用.env.production 变量。我有 .env.staging 用于“暂存”环境。我该怎么做?
我在一些生产服务器上使用不同的 API 端点,这就是我需要这种模式的原因。
【问题讨论】: