我有一个angularfire应用程序,当我在我的localhost中运行它时,它非常有用。当我将它部署到firebase时,它不会在控制台或浏览器的控制台中给我任何错误。当我检查页面时,我可以看到我的app-root组件但是它没有加载组件,所以我的页面显示为空白。
的index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JM</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
</head>
<body>
<app-root></app-root>
</body>
</html>
firebase.json
{
"hosting": {
"public": "src"
}
}
文件结构:
我跑去部署到firebase的命令:
ng build --prod
firebase deploy
运行这些命令时没有错误
答案 0 :(得分:2)
您的托管配置已设置为部署&#34; src&#34;文件夹,它不是有效的浏览器代码。它都是TypeScript。你需要部署&#34; dist&#34;文件夹,它是在浏览器中工作的已编译代码。
将您的firebase.json
更改为:
{
"hosting": {
"public": "dist"
}
}