Poo*_*han 6 firebase angularfire angular5
当应用程序在浏览器中加载时,它会发出以下警告。所以无法为 prod ( ng build --aot --prod)创建构建
It looks like you're using the development build of the Firebase JS SDK.
When deploying Firebase apps to production, it is advisable to only import
the individual SDK components you intend to use.
For the module builds, these are available in the following manner
(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):
CommonJS Modules:
const firebase = require('firebase/app');
require('firebase/<PACKAGE>');
ES Modules:
import firebase from 'firebase/app';
import 'firebase/<PACKAGE>';
Run Code Online (Sandbox Code Playgroud)
我正在使用以下配置
Angular CLI: 1.5.0
Node: 9.8.0
Angular: 5.1.3
"firebase": "^5.0.4",
"angularfire2": "^5.0.0-rc.10"
Run Code Online (Sandbox Code Playgroud)
请指导我哪里出错了。
没有什么真正的错误,这更多的是一个警告和最佳实践提示。
Firebase 由不同的服务/模块组成,例如实时数据库、Firestore、身份验证服务等。
在大多数项目中,人们不会使用所有这些服务,因此此警告表明,与其通过一次全局导入导入所有服务,不如仅导入应用程序中真正需要的服务。通过这种方式,您的构建将得到优化:生成的构建文件将仅包含您需要的 Firebase SDK 代码,而不会包含未使用的部分。
请参阅此文档项: https: //firebase.google.com/docs/web/setup,特别是以下部分:
如果您使用的是 Browserify 或 webpack 等捆绑程序,则只需 require() 您使用的组件即可。
根据您的评论更新:
使用 import 关键字,您应该执行以下操作:
import messaging from 'firebase/messaging';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3725 次 |
| 最近记录: |