How to import Firebase only on client in Sapper?

后端 未结 3 929
猫巷女王i
猫巷女王i 2021-02-05 15:09

I\'m importing Firebase into my Sapper application, I do not want the imports to be evaluated on the server. How do I make sure imports are only on the client-side?

I

3条回答
  •  广开言路
    2021-02-05 15:42

    So I have spent too much time on this. There isn't really a more elegant solution than onMOunt.

    However, I did realize that sapper really should be used for it's SSR capabilities. And I wrote an article about how to get set up on Firebase with Sapper SSR and Cloud Functions:

    https://dev.to/eckhardtd/how-to-host-a-sapper-js-ssr-app-on-firebase-hmb

    Another solution to original question is to put the Firebase CDN's in the global scope via the src/template.html file.

    
        
        
    %sapper.html%
    %sapper.scripts%

    and in the component:

    
    
    
    

提交回复
热议问题