admin管理员组文章数量:1356774
I am using Firebase Hosting to deploy my app
As you can see, I have 2 apps: clone-a50db
and clone-eeb88
and the app clone-eeb88
is already in use, so now I want to deploy my app to the other which is clone-a50db
.
This is how I did:
firebase init
? Are you ready to proceed? Yes
? Which Firebase CLI features do you want to set up for this folder? Press Space to select features, then Enter to confirm your choices. Hosting: Configure and deploy Firebase Hosting sites`
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
i .firebaserc already has a default project, using clone-eeb88.
=== Hosting Setup
Your public directory is the folder (relative to your project directory) that
will contain Hosting assets to be uploaded with firebase deploy. If you
have a build process for your assets, use your build's output directory.`
? What do you want to use as your public directory? build
? Configure as a single-page app (rewrite all urls to /index.html)? Yes
? Set up automatic builds and deploys with GitHub? No
+ Wrote build/index.html
i Writing configuration info to firebase.json...
i Writing project information to .firebaserc...
+ Firebase initialization plete!`
npm run build
firebase deploy --only hosting` (because I already deployed function in advanced)
It worked but instead of deploy to clone-a50db
, it deployed to clone-eeb88
, it is feasible because it is using default project which is clone-eeb88
as it told in the setup, please tell me how to switch my site, thank you so much and happy new year
firebase.json
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
],
"source": "functions"
}
}
I am using Firebase Hosting to deploy my app
As you can see, I have 2 apps: clone-a50db
and clone-eeb88
and the app clone-eeb88
is already in use, so now I want to deploy my app to the other which is clone-a50db
.
This is how I did:
firebase init
? Are you ready to proceed? Yes
? Which Firebase CLI features do you want to set up for this folder? Press Space to select features, then Enter to confirm your choices. Hosting: Configure and deploy Firebase Hosting sites`
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
i .firebaserc already has a default project, using clone-eeb88.
=== Hosting Setup
Your public directory is the folder (relative to your project directory) that
will contain Hosting assets to be uploaded with firebase deploy. If you
have a build process for your assets, use your build's output directory.`
? What do you want to use as your public directory? build
? Configure as a single-page app (rewrite all urls to /index.html)? Yes
? Set up automatic builds and deploys with GitHub? No
+ Wrote build/index.html
i Writing configuration info to firebase.json...
i Writing project information to .firebaserc...
+ Firebase initialization plete!`
npm run build
firebase deploy --only hosting` (because I already deployed function in advanced)
It worked but instead of deploy to clone-a50db
, it deployed to clone-eeb88
, it is feasible because it is using default project which is clone-eeb88
as it told in the setup, please tell me how to switch my site, thank you so much and happy new year
firebase.json
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
],
"source": "functions"
}
}
Share
Improve this question
edited Dec 26, 2020 at 23:28
Doug Stevenson
318k36 gold badges456 silver badges473 bronze badges
asked Dec 26, 2020 at 23:01
16020278 Đỗ Đức Tâm16020278 Đỗ Đức Tâm
2276 silver badges14 bronze badges
1
-
You have to specify target for hosting where you wish to deploy. here is a wonderful documentation to solve your problem: firebase.google./docs/cli/targets. Refer to
firebase.json
file to configure – aspirinemaga Commented Dec 26, 2020 at 23:08
1 Answer
Reset to default 11** UPDATED **
What you actually want is "Multihosting".
To manage two different versions of the same sites, you have to separate them by the targets in your firebase.json -> hosting
file, something like this:
Here is the example template project on GitHub where I'm using a Firebase Multihosting support.
{
"hosting": [
{
"target": "alpha",
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
{
"target": "beta",
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
],
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
],
"source": "functions"
}
}
Instead of using "site" property inside your firebase.json
like before, now you have to set it manually first like so:
firebase target:apply hosting alpha clone-eeb88
firebase target:apply hosting beta clone-a50db
Afterwards, you will be able to use your Firebase CLI mands like so:
firebase deploy --only hosting:alpha
firebase deploy --only hosting:beta
本文标签: javascriptFirebase deploy to another siteStack Overflow
版权声明:本文标题:javascript - Firebase deploy to another site - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744061348a2584182.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论