手順
gitignoreに.envに入れる
gitignore .env
.envに環境変数を設定する
REACT_APP_FIREBASE_KEY="your_key" REACT_APP_FIREBASE_DOMAIN="your_app_id.firebaseapp.com" REACT_APP_FIREBASE_DATABASE="https://your_app_id.firebaseio.com" REACT_APP_FIREBASE_PROJECT_ID="your_app_id" REACT_APP_FIREBASE_STORAGE_BUCKET="your_storage_bucket" REACT_APP_FIREBASE_SENDER_ID="sender_id"
呼び出す
接頭辞にREACT_を入れる必要があるらしい
export const app = firebase.initializeApp({ apiKey: process.env.REACT_APP_FIREBASE_KEY, authDomain: process.env.REACT_APP_FIREBASE_DOMAIN, databaseURL: process.env.REACT_APP_FIREBASE_DATABASE, projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID, storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET, messagingSenderId: process.env.REACT_APP_FIREBASE_SENDER_ID });