【问题标题】:How to deploy flutter web on Heroku如何在 Heroku 上部署 Flutter Web
【发布时间】:2020-10-05 10:20:24
【问题描述】:

i 在 Flutter 中构建一个 Web 应用程序并成功运行命令 flutter build web。我试图找到一种方法将其部署在 Heroku 上,就像我的反应应用程序一样,但在 heroku 文档中一无所获。

【问题讨论】:

  • 您在部署之前尝试过创建 Procfile 吗?
  • 我通过将 build/web 文件夹复制到另一个名为 release 的文件夹,然后将它的 index.php 添加到发布文件夹,然后创建一个 Procfile 指向发布文件夹,将它托管在 heroku 上。你可以使用 heroku 支持的任何其他语言,不必是 php。

标签: flutter web heroku deployment server


【解决方案1】:

我们在php的帮助下运行flutter web或静态页面运行。我们可以使用许多其他语言。我们可以简单地使用php而无需更多工作。
第一的 在显示之后在heroku中创建应用程序。

在项目文件夹的根目录中运行flutter build web 后,它将在 build/web 中生成静态内容。将文件复制到任何其他目录并像这样打开 cmd

创建两个文件 index.php 和 composer.json 在 index.php 中 添加这个

echo '<?php include_once("index.html"); ?>'

在作曲家.json 添加这个(大括号)
{} 

在运行命令后

`heroku login`
heroku git:clone -a appname
git add .
git commit -am "make it better
git push heroku master

运行后可能会显示任何错误。如果不显示任何错误 运行此https://appname.herokuapp.com/#/。您的网站将上线。

【讨论】:

    猜你喜欢
    • 2019-09-27
    • 2022-09-25
    • 2021-01-06
    • 2013-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-07
    • 1970-01-01
    相关资源
    最近更新 更多