如何在第二个 Firebase 主机中部署 Flutter Web 应用程序?
How to deploy a Flutter Web App in a Second Firebase Hosting?
在名为 originalawesome
的 Firebase 项目中,我在 Firebase Hosting 上设置了第二个站点,然后我有:
originalawesome.web.app
secondawesome.web.app
第一个 (originalawesome
) 在生产中有一个 JS 应用程序。
在第二个 (secondawesome
) 中,我想安装一个 Flutter Web 应用程序,为此我将执行以下步骤:
firebase init
(I select Hosting)
(I select to use an existing project)
(I select the project - originalawesome) //secondawesome is not an option
它要求我 select 要发布的目录,所以我想 Flutter Web 应用程序将在我的生产站点上发布,这是错误的。
阅读Share project resources across multiple sites 中的文档,当要在不同站点进行部署时,要求Deploy Targets
使用以下命令进行区分:
firebase target: apply hosting secondawesome secondawesome
但是,当我 运行 它时,我收到一个错误,因为我还没有 firebase json 文件。
Error: Not in a Firebase app directory (could not locate
firebase.json)
问题是,如何在不删除前一个的情况下在第二个 Firebase 主机上部署 Flutter Web 应用程序?
经过大量的反复试验,解决方案如下:
在应用程序根目录中(非常重要):
flutter build web --web-renderer html //In my case, I will
//generate html web rendered. It will create a firebase.json
//file and others
firebase target:apply hosting originalawesome originalawesome
firebase target: apply hosting secondawesome secondawesome
//It will create records in .firebaserc file
在firebase.json文件中,您需要包含:
{
"hosting": {
"target": "secondawesome", //deploy target
//(previously created on Firebase Hosting Console)
"public": "build/web", //build/web is the directory of the Flutter Web App build
///rest of file
现在是的,运行...
firebase init
? What do you want to use as your public directory? build/web
? Configure as a single-page app (rewrite all urls to /index.html)?
Yes
? Set up automatic builds and deploys with GitHub? No
? File build/web/index.html already exists. Overwrite? No
完成并将文件上传到 Firebase 托管...
firebase deploy --only hosting:secondawesome
我希望它对其他人有用!!
在名为 originalawesome
的 Firebase 项目中,我在 Firebase Hosting 上设置了第二个站点,然后我有:
originalawesome.web.app
secondawesome.web.app
第一个 (originalawesome
) 在生产中有一个 JS 应用程序。
在第二个 (secondawesome
) 中,我想安装一个 Flutter Web 应用程序,为此我将执行以下步骤:
firebase init
(I select Hosting)
(I select to use an existing project)
(I select the project - originalawesome) //secondawesome is not an option
它要求我 select 要发布的目录,所以我想 Flutter Web 应用程序将在我的生产站点上发布,这是错误的。
阅读Share project resources across multiple sites 中的文档,当要在不同站点进行部署时,要求Deploy Targets
使用以下命令进行区分:
firebase target: apply hosting secondawesome secondawesome
但是,当我 运行 它时,我收到一个错误,因为我还没有 firebase json 文件。
Error: Not in a Firebase app directory (could not locate firebase.json)
问题是,如何在不删除前一个的情况下在第二个 Firebase 主机上部署 Flutter Web 应用程序?
经过大量的反复试验,解决方案如下:
在应用程序根目录中(非常重要):
flutter build web --web-renderer html //In my case, I will
//generate html web rendered. It will create a firebase.json
//file and others
firebase target:apply hosting originalawesome originalawesome
firebase target: apply hosting secondawesome secondawesome
//It will create records in .firebaserc file
在firebase.json文件中,您需要包含:
{
"hosting": {
"target": "secondawesome", //deploy target
//(previously created on Firebase Hosting Console)
"public": "build/web", //build/web is the directory of the Flutter Web App build
///rest of file
现在是的,运行...
firebase init
? What do you want to use as your public directory? build/web
? Configure as a single-page app (rewrite all urls to /index.html)? Yes
? Set up automatic builds and deploys with GitHub? No
? File build/web/index.html already exists. Overwrite? No
完成并将文件上传到 Firebase 托管...
firebase deploy --only hosting:secondawesome
我希望它对其他人有用!!