[英]firebase.json change public folder dynamically
I have an angular7/ionic4 app with 2 environments for staging and prod. 我有一个angular7 / ionic4应用程序,具有用于登台和生产的2个环境。
I can do 我可以
ionic build 离子生成
ionic build --prod 离子生成--prod
This publishes the app in different folders I have set in angular.json 这会将应用程序发布到我在angular.json中设置的不同文件夹中
dist/staging dist / staging
dist/prod dist / prod
I also have 2 projects in firebase and can deploy to each 我在Firebase中也有2个项目,可以部署到每个项目中
firebase deploy -P staging Firebase部署-P过渡
firebase deploy -P default firebase deploy -P默认
However in firebase.json I can only set one hosting folder from where to pick the files up to send to firebase: 但是在firebase.json中,我只能设置一个托管文件夹,从中可以拾取文件以发送到firebase:
"hosting": {
"public": "dist/prod"
}
So despite being able to deploy to different projects I can't seem to set which folder to deploy from. 因此,尽管能够部署到不同的项目,但我似乎无法设置要从哪个文件夹进行部署。
I want 我想要
firebase deploy -P default firebase deploy -P默认
to deploy files from dist/prod 从dist / prod部署文件
and 和
firebase deploy -P staging Firebase部署-P过渡
to deploy files from dist/staging 从dist / staging部署文件
Can I change firebase.json (or .firebaserc) to set which folder to deploy from for each environment / project ? 我可以更改firebase.json(或.firebaserc)以设置每个环境/项目要从哪个文件夹部署吗?
Associate the sites with a local target so Firebase knows which code to deploy where. 将站点与本地目标相关联,以便Firebase知道将哪些代码部署到哪里。
$ firebase target:apply hosting staging staging_project_name
$ firebase target:apply hosting prod production_project_name
And then edit the configuration in the firebase.json
file as follows: 然后在firebase.json
文件中编辑配置,如下所示:
{
"hosting": [ {
"target": "staging",
"public": "dist/staging",
"rewrites": [...]
},
{
"target": "prod",
"public": "dist/prod",
"rewrites": [...]
}
]
}
And then you can deploy as follows: 然后您可以按以下方式进行部署:
$ firebase deploy --only hosting:staging -P staging
$ firebase deploy --only hosting:prod -P default
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.