2017-09-02 187 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.