[英]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.以下是我已采取的部署步骤。
ng build --prod
againng build --prod
dist
directory hence I copied all the content from the subdirectory which contains index.html to dist/
. dist
目录内的子文件夹中,因此我将包含 index.html 的子目录中的所有内容复制到dist/
。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:这对我有用:
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
不
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.