如何停止警告:您似乎正在使用 Firebase JS SDK 的开发版本?

2024-03-16

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 CDN builds, these are available in the following manner
(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):

https://www.gstatic.com/firebasejs/5.0.0/firebase-<PACKAGE>.js

它占用了我已经有限的控制台空间的一半:(

Note:我在 html 中使用 firebase .. 并带有脚本标签。我不使用此处解释的导入语法:类似的问题 https://stackoverflow.com/questions/50707211/warning-it-looks-like-youre-using-the-development-build-of-the-firebase-js-sdk

如何停止这个警告?


为了更清楚地回答这个问题,

你最有可能拥有的是

<script src="https://www.gstatic.com/firebasejs/6.0.2/firebase.js"></script>

因为这是 Firebase 从“将 Firebase 添加到您的 Web 应用程序”屏幕中为您提供的内容。

但是,它所做的是导入所有 Firebase 模块。我不知道为什么 Firebase 将其作为生成的脚本,但您所需要做的就是将 -app 添加到源中,现在就是这样。

<script src="https://www.gstatic.com/firebasejs/6.0.2/firebase-app.js"></script>

然后,对于您想要使用的 Firebase 的每个后续功能,您将需要添加另一个脚本行。例如,如果您想将云消息传递添加到您的网络应用程序中,则只需要。

<script src="https://www.gstatic.com/firebasejs/6.0.2/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.0.2/firebase-messaging.js"></script>

您可以找到更多信息,包括完整的进口清单来自 Firebase。 https://firebase.google.com/docs/web/setup?authuser=0

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何停止警告:您似乎正在使用 Firebase JS SDK 的开发版本? 的相关文章

随机推荐