webpack import firebase not working

后端 未结 1 1040
小鲜肉
小鲜肉 2021-02-08 00:46

I\'m having an issue getting firebase 3.0.1 to work. I have a feeling it\'s in regards to my webpack setup. My files are below. When running my app with webpack dev server I get

相关标签:
1条回答
  • 2021-02-08 01:23

    I had the same problem, there's a simple fix though:

    var firebase = require('firebase/app');
    

    This way you get the "real" firebase module. However you must now require each module you'll need so it loads correctly, like so:

    var firebase = require('firebase/app');
    // all 3 are optional and you only need to require them at the start
    require('firebase/auth');
    require('firebase/database');
    require('firebase/storage');
    

    It seems to me that something is wrong with the current initialisation code, looking at the source it should work; but then again, somewhat like you, I'm using browserify, and haven't tested outside of it, so it might be related.

    0 讨论(0)
提交回复
热议问题