简体   繁体   English

Firebase 托管在部署 Angular 6 应用程序后显示欢迎页面?

[英]Firebase hosting showing welcome page after deploying angular 6 app?

I want to develop the angular 6 apps, but after deploying firebase showing only welcome page.我想开发 angular 6 应用程序,但在部署 firebase 后只显示欢迎页面。

Here are the steps I have taken to deploy.以下是我已采取的部署步骤。

  1. installed firebase-tools安装的 firebase-tools
  2. ng build --prod (in my app) ng build --prod(在我的应用程序中)
  3. firebase init火力初始化
  4. Are you ready to proceed?你准备好继续了吗? (Y/n) y (是/否)是
  5. (*) Hosting: Configure and deploy Firebase Hosting sites (*) 托管:配置和部署 Firebase 托管站点
  6. What do you want to use as your public directory?你想用什么作为你的公共目录? (public) dist (公共)分布
  7. Configure as a single-page app (rewrite all urls to /index.html)?配置为单页应用程序(将所有 url 重写为 /index.html)? (y/N) y (是/否)是
  8. File dist/index.html already exists.文件 dist/index.html 已经存在。 Overwrite?覆盖? (y/N) y (是/否)是
  9. Firebase initialization complete! Firebase 初始化完成!
  10. In this step, I have deleted dist folder and run ng build --prod again在此步骤中,我删除了 dist 文件夹并再次运行ng build --prod
  11. angular build app in a subfolder inside dist directory hence I copied all the content from the subdirectory which contains index.html to dist/ . angular build app 在dist目录内的子文件夹中,因此我将包含 index.html 的子目录中的所有内容复制到dist/
  12. firebase deploy火力基地部署
  13. firebase open hosting:site firebase 开放托管:网站

but after doing all that I am still getting welcome page in the link.但在完成所有这些之后,我仍然在链接中获得欢迎页面。

What am I doing wrong??我究竟做错了什么??

Try: 8. File dist/index.html already exists.试试: 8. 文件 dist/index.html 已经存在。 Overwrite?覆盖? (y/N) N and open link to your app in incognito mode. (y/N) N 并以隐身模式打开指向您的应用程序的链接。 Seriously, I stuck for hours because this firebase index got cached in my case, so this was the reason why I could't see my app after deploy.说真的,我坚持了几个小时,因为这个 firebase 索引在我的案例中被缓存了,所以这就是为什么我在部署后看不到我的应用程序的原因。

Browser cache was my issue as well.浏览器缓存也是我的问题。 As mentioned above, try in incognito or use proxysite.com (very useful website) to avoid browser cache如上所述,尝试隐身或使用 proxysite.com(非常有用的网站)以避免浏览器缓存

In my case, I was initializing firebase inside the project directory ( src ).就我而言,我在项目目录( src )中初始化 firebase 。 Just check the directory you are in. It should be on the top level.只需检查您所在的目录。它应该在顶层。

After you build it and try to deploy it, it will be the same since the web page has been cached.在您构建它并尝试部署它之后,它将是相同的,因为 web 页面已被缓存。 So to make sure use in incognito .所以要确保使用incognito

The Problem is: firebase is looking for the index.html file, sometimes it is not present directly in the dist directory问题是: firebase 正在寻找index.html文件,有时它不直接存在于dist目录中

Solution: update the public path in the firebase.json to "public":"dist/ProjectName" or path to the index.html file in the dist folder解决方法:firebase.json中的public路径更新为"public":"dist/ProjectName"或者dist文件夹下index.html文件的路径

Example例子

{
  "hosting": {
    "public": "dist/<YourProjectName>",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/dist/index.html"
      }
    ]
  }
}

This worked for me:这对我有用:

  • Delete.firebase folder删除.firebase文件夹
  • Delete.firebaserc删除.firebaserc
  • Delete firebase.json删除firebase.json

Now run as follow:现在运行如下:

$ firebase init hosting
? File build/web/index.html already exists. Overwrite? No
$ firebase deploy --only hosting

Check the path on terminal.if the problem still exists then delete firebase auto created folders and deploy the project检查终端上的路径。如果问题仍然存在,则删除 firebase 自动创建的文件夹并部署项目

Configure as a single-page app (rewrite all urls to /index.html)?配置为单页应用(将所有 url 重写为 /index.html)? No?不? Set up automatic builds and deploys with GitHub?使用 GitHub 设置自动构建和部署? No

  • Wrote public/404.html?写了 public/404.html? File public/index.html already exists.文件 public/index.html 已经存在。 Overwrite?覆盖? No

This error is generated by index.html inside public folder of your website folder.此错误是由您网站文件夹的公共文件夹中的 index.html 生成的。

firebase init hosting? firebase 初始化托管? File build/index.html already exists.文件 build/index.html 已经存在。 Overwrite?覆盖? No npm run build firebase deploy --only hosting否 npm 运行构建 firebase 部署——仅托管

In my case I had to change public to dist in firebase.json so it pointed to my dist folder (rather than the public folder which contains the holding page) after I added Firebase Functions to my project:在我的例子中,我必须在 firebase.json 中将public更改为dist ,以便在我将 Firebase Functions 添加到我的项目后它指向我的 dist 文件夹(而不是包含保留页面的 public 文件夹):

"hosting": {
   "public": "dist",
   ...
}

The welcome page is an automatically generated index.html file found in public folder.欢迎页面是在public文件夹中自动生成的 index.html 文件。 I replaced that file with my own index.html file, then use firebase deploy --only hosting commands to update the changes.我用自己的 index.html 文件替换了该文件,然后使用firebase deploy --only hosting命令来更新更改。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 react-app 部署到 firebase 主机时出现空白页? - blank page when deploying react-app into firebase hosting? Firebase 主机没有显示应用程序? - Firebase hosting not showing up app? 在 firebase flutter web 项目上部署后显示白色空白页 - After deploying on firebase flutter web project showing white blank page Flutter web 应用程序丢失 firebase.json 并在部署到 firebase 托管时显示“欢迎 Firebase 托管设置完成” - Flutter web app is missing firebase.json and shows "Welcome Firebase Hosting Setup Complete" when deployed to firebase hosting 部署失败 Firebase 使用简单的 Angular 应用程序托管 - Deployment fails to Firebase Hosting with simple Angular App Flutter web 应用程序在部署到 firebase 主机后返回空白页 - Flutter web app is returning blank page after being deployed to firebase hosting 将Quasar app部署到Firebase时出现空白页面 - Blank page when deploying Quasar app to Firebase 我正在处理一个 flutter web 项目,当我在本地主机上运行时它工作正常但在 firebase 中部署后它显示白色空白页 - I'm working on a flutter web project ,when i run in localhost it is working fine but after deploying in firebase it is showing white blank page 将 React 应用程序部署到 firebase 会将我带到 firebase 着陆页 - deploying react app to firebase takes me to firebase landing page Flutter:使用欢迎页面启动应用程序 - Flutter : starting the app with welcome page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM