对于我的项目,我使用登台和生产环境。angular.json 中的 fileReplacements 属性用于更改文件:
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
},
{
"replace": "src/app.html",
"with": "src/app.prod.html"
}
]
Run Code Online (Sandbox Code Playgroud)
使用 .firebaserc 文件在环境之间进行更改。
现在我需要为每个环境使用不同的 firebase 配置文件( firebase.json 和 firebase.prod.json )是否可以做到?我想使用预部署脚本,但不知道如何
I have done it using single .firebaserc file. You can add different targets to deploy.
firebase target:apply type target-name resource-name
ref: [ https://firebase.google.com/docs/cli/targets && https://firebase.google.com/docs/cli/ ]
// firebase.json
"hosting": [
{
"target": "prod",
"public": "dist/<folder_name>,
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
// .firebaserc file // Sample: here the "projects" are your targets
{
"projects": {
"default": "staging-project",
"dev": "staging-project",
"prod": "prod-project"
},
"targets": {
"staging-project": {
"hosting": {
"stage": [
"staging-project"
],
"admin-stage": [
"your-admin-stage"
],
"admin-prod": [
"your-admin-prod"
],
"prod": [
"prod-project"
]
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
// in the build script
firebase use dev
firebase deploy --only firestore:rules,hosting:stage,functions...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3096 次 |
| 最近记录: |