Reputation: 3593
For my project I use staging and production environment. fileReplacements property inside angular.json is used to change files:
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
},
{
"replace": "src/app.html",
"with": "src/app.prod.html"
}
]
to change between environments .firebaserc files is used.
Now I need to use different firebase config files per environment ( firebase.json and firebase.prod.json ) Is it possible to do it? I thought to use predeploy scrips, but don't know how
Upvotes: 7
Views: 4811
Reputation: 1759
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"
}
]
}
]
// .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"
]
}
}
}
}
// in the build script
firebase use dev
firebase deploy --only firestore:rules,hosting:stage,functions...
Upvotes: 10