I´m trying to deploy my code to two different Firebase-projects, one for development and one for production.
The my-app-dev
project was already included and working, so I added the my-app
(for production) with firebase use --add
and selected the my-app
.
This is how my Firebase-config looks now:
.firebaserc
{
"targets": {
"my-app-dev": {
"hosting": {
"app": [
"my-app-dev"
]
}
}
},
"projects": {
"default": "my-app-dev",
"prod": "my-app"
}
}
firebase.json
{
"hosting": [
{
"target": "app",
"public": "dist/app",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
],
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
}
}
As long as I deploy to my default project, everything works fine, but when I try to firebase deploy -P prod
it shows the following error:
Deploy target app not configured for project my-app. Configure with:
firebase target:apply hosting app <resources...>
I tried to find some more information about this command, but still don´t know what to put for resources. Overall I feel like the .firebaserc
has a very confusing structure.
According to this comment in GitHub it cannot be done without a "hacky" method like swapping the firebase.json programmatically during deploying.
Right now the Firebase CLI is built to treat projects as anonymous environments that are functionally identical. This is important to be able to deploy the same assets to multiple projects without having to alter the code (including in firebase.json).
To achieve what you want, you'll need to set up a dev and prod folder, each with their own firebase.json and each with a target only for that specific project. Deploying different assets to different projects is not supported now and is unlikely to be supported in the future (however, we may allow configuring the location of firebase.json via a flag at some point).