Firebase 部署到另一个站点
Firebase deploy to another site
我正在使用 Firebase 托管来部署我的应用程序
如您所见,我有 2 个应用程序:clone-a50db
和 clone-eeb88
并且应用程序 clone-eeb88
已经在使用中,所以现在我想将我的应用程序部署到另一个应用程序这是 clone-a50db
.
我是这样做的:
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 complete!`
npm run build
firebase deploy --only hosting` (because I already deployed function in advanced)
它起作用了,但它没有部署到 clone-a50db
,而是部署到 clone-eeb88
,这是可行的,因为它使用的是默认项目,正如它在设置中所说的那样,clone-eeb88
,请告诉我如何切换我的网站,非常感谢,新年快乐
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"
}
}
** 已更新 **
您真正想要的是“多主机”。
要管理同一站点的两个不同版本,您必须通过 firebase.json -> hosting
文件中的 targets 将它们分开,如下所示:
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"
}
}
不像以前那样在 firebase.json
中使用“站点”属性,现在您必须先手动设置它,如下所示:
firebase target:apply hosting alpha clone-eeb88
firebase target:apply hosting beta clone-a50db
之后,您将能够像这样使用 Firebase CLI 命令:
firebase deploy --only hosting:alpha
firebase deploy --only hosting:beta
我正在使用 Firebase 托管来部署我的应用程序
如您所见,我有 2 个应用程序:clone-a50db
和 clone-eeb88
并且应用程序 clone-eeb88
已经在使用中,所以现在我想将我的应用程序部署到另一个应用程序这是 clone-a50db
.
我是这样做的:
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 complete!`
npm run build
firebase deploy --only hosting` (because I already deployed function in advanced)
它起作用了,但它没有部署到 clone-a50db
,而是部署到 clone-eeb88
,这是可行的,因为它使用的是默认项目,正如它在设置中所说的那样,clone-eeb88
,请告诉我如何切换我的网站,非常感谢,新年快乐
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"
}
}
** 已更新 **
您真正想要的是“多主机”。
要管理同一站点的两个不同版本,您必须通过 firebase.json -> hosting
文件中的 targets 将它们分开,如下所示:
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"
}
}
不像以前那样在 firebase.json
中使用“站点”属性,现在您必须先手动设置它,如下所示:
firebase target:apply hosting alpha clone-eeb88
firebase target:apply hosting beta clone-a50db
之后,您将能够像这样使用 Firebase CLI 命令:
firebase deploy --only hosting:alpha
firebase deploy --only hosting:beta