- React
- React Redux
- redux-thunk
- react-redux-firebase
- Materialize (Meterial Design)
- Firebase Authentication(Email・パスワード認証)
- Cloud Firestore (users, projects)
- Cloud Functions
- Hosting(デプロイ先として使う)
- Node v10.16.0
- create-react-app
- Firebaseコンソールでプロジェクトを作成しウェブアプリを追加
- Authentication, Database(Cloud Firestore), Functions, Hostingを有効にする
- Databaseの「ルール」タブでアクセス権限を設定
service cloud.firestore {
match /databases/{database}/documents {
match /projects/{project} {
allow read, write: if request.auth.uid != null
}
match /users/{userId} {
allow create
allow read: if request.auth.uid != null
allow write: if request.auth.uid == userId
}
match /notifications/{notification} {
allow read: if request.auth.uid != null
}
}
}
- プロジェクトの設定 > Firebase SDK snippetから構成情報をコピーして
config/firebase.js
のexport const firebaseConfig
を上書きする
Firebaseコマンドをインストール。
npm install -g firebase-tools
ソースコードのディレクトリで、Firebaseのセットアップ。
firebase login
firebase init
どのFirebaseサービスと関連付けるかを聞かれるので、FunctionsとHostingをスペースキーで選択。
? Which Firebase CLI features do you want to set up for this folder? Press Space to select features, then Enter to confirm your choices. (Press <space> to select, <a> to toggle all, <i> to invert selection)
◯ Database: Deploy Firebase Realtime Database Rules
◯ Firestore: Deploy rules and create indexes for Firestore
◉ Functions: Configure and deploy Cloud Functions
❯◉ Hosting: Configure and deploy Firebase Hosting sites
◯ Storage: Deploy Cloud Storage security rules
Functionsの言語はJavascript
を選択。
? What language would you like to use to write Cloud Functions? JavaScript
deployするファイルを配置する場所はpublic
ではなくdist
に変更する。
? What do you want to use as your public directory? (public)
その他の設問はお好みで。
Firebase Functionsのコードはfunctionsディレクトリにある。
cd functions
npm install
npm install
npm start
npm run build
npm run deploy
npm test