如何使用自定义模式制作React应用的生产版本?

问题描述 投票:0回答:1

[使用带有"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变量。我在[STAGING]环境中使用.env.staging。我该怎么办?

我在一些生产服务器上使用不同的API端点,这就是为什么我需要这种模式的原因。

reactjs npm yarn
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.