How to host Flutter Web (Hummingbird) on Firebase Hosting

房东的猫 提交于 2019-12-30 07:24:12

问题


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.

Error :

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

My Project Structure :

firebase.json :

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

Commands:

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


回答1:


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

Build

webdev 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

Correct Path:

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

I attached full command of firebase hosting deployment below,



来源:https://stackoverflow.com/questions/56206091/how-to-host-flutter-web-hummingbird-on-firebase-hosting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!