From 47a2dee457e11bbe5171837d2b9f4df220b7943a Mon Sep 17 00:00:00 2001 From: Sun Haoran Date: Wed, 3 Feb 2021 12:25:28 +0100 Subject: [PATCH] build: setup firebase emulator firebaseui emulator pending for https://github.com/firebase/firebaseui-web/issues/778 --- firebase.json | 11 ++--------- package.json | 2 +- src/main.js | 8 ++++++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/firebase.json b/firebase.json index 5d92b9c..facb2c1 100644 --- a/firebase.json +++ b/firebase.json @@ -1,11 +1,7 @@ { "hosting": { "public": "dist", - "ignore": [ - "firebase.json", - "**/.*", - "**/node_modules/**" - ], + "ignore": ["firebase.json", "**/.*", "**/node_modules/**"], "rewrites": [ { "source": "**", @@ -21,10 +17,7 @@ "port": 5001 }, "firestore": { - "port": 8080 - }, - "hosting": { - "port": 5000 + "port": 8090 }, "ui": { "enabled": true diff --git a/package.json b/package.json index e490b52..806e676 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "serve": "vue-cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint", - "emulate:func": "firebase emulators:start --only functions", + "emulate": "firebase emulators:start", "deploy:func": "firebase deploy --only functions" }, "dependencies": { diff --git a/src/main.js b/src/main.js index 495a8df..6fd4636 100644 --- a/src/main.js +++ b/src/main.js @@ -21,13 +21,17 @@ firebase.initializeApp({ /* cSpell:enable */ const functions = firebase.app().functions('europe-west1') +const db = firebase.firestore() if (process.env.NODE_ENV == 'development') { - functions.useEmulator('localhost', 5001) + const emulatorConfig = require('../firebase.json').emulators + functions.useEmulator('localhost', emulatorConfig.functions.port) + // firebase.auth().useEmulator(`http://localhost:${emulatorConfig.auth.port}/`) + db.useEmulator('localhost', emulatorConfig.firestore.port) } app.config.globalProperties.$firebase = firebase // unnecessary, but easy reference -app.config.globalProperties.$db = firebase.firestore() +app.config.globalProperties.$db = db app.config.globalProperties.$func = functions app.config.globalProperties.$user = null router.app = app