【发布时间】:2021-03-24 13:27:15
【问题描述】:
所以我使用 create-react-app 工具链创建了一个反应应用程序。 编写了一些组件并运行
firebase init
npm run build
firebase deploy --only hosting
现在,当我在 chrome dev-tools 的源选项卡中检查我的实时应用程序时,它显示了 react 应用程序的所有源文件,包括原样的 cmets。
firebase 不应该只部署构建目录中针对生产进行优化和缩小的块吗?
我运行了网络测试以查看正在获取的文件类型,令人惊讶的是,它只获取了构建目录中的块。那么我的 src 目录中的所有文件是如何以原始形式存在的呢?
现在浏览器可能会从块中构造它们。那么它似乎是一个反应构建问题,它不会在生产构建中删除 cmets 和 uglify。
但我也分析了构建目录中的 js 块,它们没有嵌入 cmets。
这是我的 firebase 配置:
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
【问题讨论】:
-
我们看不出你是否真的配置了你的部署,所以很难说为什么它没有达到你的预期。
-
@jonrsharpe 添加了 firebase 配置。先生看看
标签: reactjs firebase firebase-hosting firebase-cli