在Firebase中部署后,我的网站没有显示如何解决此问题

时间:2018-08-28 03:57:38

标签: firebase firebase-hosting

我已经完成了所有过程

  1. Firebase登录
  2. Firebase初始化
  3. Firebase部署

现在终于有了链接https://testing-37553.firebaseapp.com/ 但是我的网站没有显示,所以我该怎么办。 enter image description here

7 个答案:

答案 0 :(得分:3)

您看到的是在创建新项目时由CLI创建的默认index.html页面。

您应该随心所欲地修改此index.html页(例如,通过在本地项目目录中修改此页的HTML / CSS / JS代码),然后使用

重新部署项目
firebase deploy

firebase deploy --only hosting

答案 1 :(得分:2)

转到您的firebase.json文件,并确保将“主机”下的“公钥”设置为“ build”,如下所示:

"hosting": {
    "public": "build"
}

在运行firebase init时,默认情况下它可能设置为“ public”。在这种情况下,它将如下所示:

"hosting": {
    "public": "public"
}

默认的问题是,当您运行npm run build时,React将所有静态资产放置在“ build”目录中,因此您要将Firebase指向该目录。

答案 2 :(得分:1)

我遇到了类似的问题,我的应用程序是使用create react app构建的react。我试图通过firebase进行部署,但获取了firebase的默认页面,然后我发现我没有构建我的应用程序,因此firebase无法找到我的应用程序html文件,因此它正尝试部署默认文件。

我通过运行yarn build解决了这个问题,然后当我执行firebase init时选择了“ hosting”选项。在执行此步骤之后,选择要部署的文件夹而不是公共文件夹时,我选择了“ build”,这解决了我的问题,并且托管了我的应用程序。希望这会有所帮助!

答案 3 :(得分:0)

对于Angular 7 +,这是自2019年8月起对我有效的直接解决方案 只需删除index.html文件夹根目录下的/dist文件即可。 然后,复制directory(named like your project main project folder's name)文件夹中/dist内的所有内容

最后,重新运行firebase deploy

很高兴!

答案 4 :(得分:0)

对于Angular 8。

如果您的项目名称是“ ManyuDictionary”。

1)运行firebase登录。

2)运行firebase init并选择:

a)托管

b)您想使用什么作为公用目录? dist / ManyuDictionary

c)配置为单页应用程序(将所有URL重写为/index.html)?是的。

Firebase现在将配置信息写入firebase.json和项目 信息发送到.firebaserc。

3)运行ng build --prod。这将替换dist / ManyuDictionary中的默认index.html。

4)运行firebase deploy。

这是您的网站[https://manyudictionary.firebaseapp.com]

答案 5 :(得分:0)

截至2020年9月17日对我有用的解决方案

1-完成 firebase初始化步骤。

2-将此添加到您的 firebase.json 文件中:

//"public": should be, dist + project name on your computer
//"site": should be the app name which you created on your firebase cloud

{
  "hosting": {
    "public": "dist/your-project-name",
    "site": "firebase-project-name",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

3- ng build --prod

4- Firebase部署

答案 6 :(得分:0)

Firebase 会在您输入 firebase init hosting 时询问。

File dist/your-project/index.html already exists. Overwrite?

NO

你可以走了!