cra创建的react项目,如何用start命令跑线上环境?

cra的文档地址
https://www.html.cn/create-re...

我这里定义了接口环境变量
.env.production

REACT_APP_API_URL=https://xxx.com

.env.development

REACT_APP_API_URL=http://localhost:3001

然后package.json中

"start:dev": "yarn run start",
"start:prd": "yarn run start",

现在我想本地跑线上的环境,start:prd命令应该怎么写?

阅读 2k
1 个回答

使用 --mode 指定就可以了。
yarn run start --mode production

具体文档 👉 Mode | webpack

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题