Import only auth and firestore from firebase

2020-06-08 06:27发布

问题:

I am attempting to reduce the firebase library size in my vuejs app. I currently import firebase as

import * as firebase from 'firebase';
require("firebase/firestore");

Inside my vendor file I have the database and messaging services but I have no use for them.

How do I go about only importing auth and firestore into firebase object?

回答1:

First you need to import the core

import * as firebase from 'firebase/app';

then import required modules

import 'firebase/auth';
import 'firebase/firestore';

or

var firebase = require("firebase/app");
require("firebase/auth");
require("firebase/database");