| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

Angular Firebase 構築手順

提供: MyMemoWiki
2020年10月31日 (土) 03:01時点におけるPiroto (トーク | 投稿記録)による版 (→‎設定の確認)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

| Angular | Firebase | Google Cloud Platform |

Angular Firebase 構築手順

Firebase Hosting に Angular を統合して Firestore に接続

Angular

  • project name : typea-info-service
  1. $ npm install -g @angular/cli
  2. $ ng new typea-info-service
  3. ? Would you like to add Angular routing? Yes
  4. ? Which stylesheet format would you like to use? SCSS [ https://sass-lang.com/documentation/syntax#scss
  5. ]
  6. CREATE typea-info-service/README.md (1035 bytes)
  7. :
  8. $ ng serve

Firebase

  • 必要なモジュールなどを対話で選択
  1. $ cd typea-info-service
  2. $ firebase init

Config

Fire base condig01.png

Fire base condig02.png

  1. Config
  2. export const environment = {
  3. production: false,
  4. firebase: {
  5. apiKey: '<your-key>',
  6. authDomain: '<your-project-authdomain>',// {project-id}.firebaseapp.com
  7. databaseURL: '<your-database-URL>',// https://{project-id}.firebaseio.com
  8. projectId: '<your-project-id>',
  9. storageBucket: '<your-storage-bucket>',// {project-id}.appspot.com
  10. messagingSenderId: '<your-messaging-sender-id>'
  11. }
  12. };

設定の確認

  • firebase.json の hosting/public デプロイ対象のフォルダを、Angularのビルド先の フォルダ(angular.json の outputPath)、distに変更する
  1. hosting”: {
  2. public”: dist”,
  • Hostingの設定/設定解除
  1. $ firebase target:apply hosting typea-info-service
  2. $ firebase target:clear hosting typea-info-service
  • 確認
  1. $ firebase target
  2. Resource targets for typea-info-service:
  3.  
  4. [ hosting ]
  5. typea-info-service (typea-info-service)

Angular Fire

  1. $ ng add @angular/fire@next
  2. $ npm install firebase @angular/fire --save

Angular Material

  1. $ ng add @angular/material