2017-09-02 207 views
1

部署应用角度我试firebase部署我angular 4的应用,但这里提到的设置没有问我任何配置:https://alligator.io/angular/deploying-angular-app-to-firebase/和许多similar answers on stack。在运行firebase init时,Firebase cli通过以下5个步骤,我只被要求step1而不是其他人。错误的火力地堡

  1. Firebase CLI功能...:托管。
  2. 数据库规则文件:您可以保留它们提供的默认文件名,或者如果您愿意,可以更改它。该文件将被创建并且 将包含您的应用程序的数据库规则。
  3. 公共目录:输入dist,因为这是您的生产就绪的Angular应用程序资产所在的位置。
  4. 配置为单页应用程序:大多数情况下,您会为此选择是(y) 。
  5. 覆盖的index.html:号

因此,在根目录下生成的firebase.json是空的:

{} 

然后,当我跑firebase deploy,我得到这个错误:

Error: Cannot understand what targets to deploy. Check that you specified valid targets if you used the --only or --except flag . Otherwise, check your firebase.json to ensure that your project is initialized for the desired features.

然后我搜索了应该已经正常创建的firebase.json内容,然后我将下面的内容粘贴到json和de这是成功的:

{ 
    "hosting": { 
    "public": "dist", 
    "rewrites": [ 
     { 
     "source": "**", 
     "destination": "/index.html" 
     } 
    ] 
    } 
} 

Firebase没有要求配置的任何理由?我在firebase.json中使用了正确的内容吗?我发现“忽略”设置以及此文件here。任何人都可以分享正确的内容。 TIA。

回答

0

运行后firebase init

Press SPACE to select hosting, then Enter to confirm.