到目前为止,我有一个具有两个环境的放大反应应用程序:prod 和 staging。
然后我的.env.staging
和.env.production
文件具有不同的 API URL 值。
因此,在我的 package.json 中,我为部署准备了以下脚本:
"build": "react-scripts build",
"build:staging": "env-cmd -f .env.staging react-scripts build",
现在问题来了,因为我不知道如何amplify publish
根据环境使命令运行其中一个或另一个。
无论amplify env checkout
我选择哪个,“发布”命令中使用的配置都在“project-config.json”中共享,如下所示:
{
"projectName": "whatever",
"version": "3.0",
"frontend": "javascript",
"javascript": {
"framework": "react",
"config": {
"SourceDir": "src",
"DistributionDir": "build",
"BuildCommand": "npm.cmd run-script build",
"StartCommand": "npm.cmd run-script start"
}
},
"providers": [
"awscloudformation"
]
}
有什么方法可以实现我想要的吗?
提前感谢您的帮助。