如何在Firebase托管上托管Flutter Web(Hummingbird)

编程入门 行业动态 更新时间:2024-10-25 09:33:32
本文介绍了如何在Firebase托管上托管Flutter Web(Hummingbird)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建了一个Flutter Web项目,并在localhost中正常工作.因此,我计划将网站托管在firebase中.我遵循了已成功部署的命令,但在控制台中仅显示黑屏,并显示错误消息.

I created a flutter web project and work fine in localhost. So I planned to host the website in firebase. I followed the commands it deployed successfully but it shows only black screen in the console it shows error message.

错误:

的源" myportfolioflutterweb.firebaseapp/加载失败. web/main.dart.js ". SyntaxError:期望的表达式,得到了'<'[了解详情]

Loading failed for the with source "myportfolioflutterweb.firebaseapp/web/main.dart.js". SyntaxError: expected expression, got '<'[Learn More]

我的项目结构:

firebase.json:

firebase.json :

{ "hosting": { "public": "public", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "redirects": [ { "source": "/", "destination": "/web/index.html", "type": 302 } ] } }

命令:

注意:当我将public dir作为公用文件夹时,它将创建index.html.我手动删除了文件,然后导航到路径为web/index.html

Note: When I give public dir as the public folder it creates index.html. I deleted the file manually and navigate to the path as web/index.html

推荐答案

最后,我解决了这个问题.我在Firebase托管的公用文件夹中导航错误的路径.要首先部署Flutter网站,我需要使用以下命令构建项目

Finally, I solved the issue. I navigate the wrong path in public folder on firebase hosting. To deploy flutter web first I need to build the project using below command

构建

webdev build

构建项目后,它将在项目内部创建一个构建文件夹 在我以root身份公开路径但正确的路径是build之前

After I build the project It creates a build folder inside the project Before I public path as root but the correct path is build

正确的路径:

What do you want to use as your public directory? build

我在下面附加了完整的Firebase托管部署命令,

I attached full command of firebase hosting deployment below,

更多推荐

如何在Firebase托管上托管Flutter Web(Hummingbird)

本文发布于:2023-11-17 05:28:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608991.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   Firebase   Flutter   Web   Hummingbird

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!