我部署了一个 Firebase 应用,并对项目中的一个 JavaScript 文件进行了更改。我从项目目录重新执行firebase deploy
,但网站上的文件没有更新。当我部署时,帐户管理显示发生了更新,但文件保持不变。我做错了什么吗?我该如何解决/解决这个问题?任何帮助,将不胜感激。
谢谢
我部署了一个 Firebase 应用,并对项目中的一个 JavaScript 文件进行了更改。我从项目目录重新执行firebase deploy
,但网站上的文件没有更新。当我部署时,帐户管理显示发生了更新,但文件保持不变。我做错了什么吗?我该如何解决/解决这个问题?任何帮助,将不胜感激。
谢谢
确保在部署之前构建您所做的任何新更改。
例如,如果您有一个 Angular 2 应用程序并且正在使用 Angular cli 类型ng build然后firebase deploy。
要清除缓存,请按 Ctr+F5 或更好地使用隐身模式进行开发。使用隐身模式强制重新加载适用于移动设备和桌面设备。
如果您使用的是 React 或 Vue,请不要忘记在运行命令firebase deploy之前运行构建命令,例如npm run build
我有同样的问题,我确实清除了缓存和所有内容,但我仍然遇到同样的问题,然后运行
yarn build
然后我可以看到我的最新变化。
在隐身窗口中尝试相同的托管 URL,当我进入隐身窗口时它对我有用,因为我在同一个窗口中维护了 localhost 和域 URL。
试试看,可能你也有问题,谢谢
刷新您的网络浏览器
在大多数 Windows 和 Linux 浏览器中:按住 Ctrl 并按 F5。
在 Apple Safari 中:按住 ⇧ Shift 并单击重新加载工具栏按钮。
在 Mac 版 Chrome 和 Firefox 中:同时按住 ⌘ Cmd+⇧ Shift 并按 R。
我希望它有帮助
来源:https ://en.wikipedia.org/wiki/Wikipedia:Bypass_your_cache
为了不再忘记build
在部署之前我把它放在我的package.json
:
"scripts": {
"build": "node build/build.js && firebase deploy"
}
这样我就不必记住它了。在部署方面尽可能自动化。
关于 React(create-react-app) - 如果有人出于同样的原因来到这里:我遇到了重新部署项目的问题。部署一开始有效,但是当我尝试重建(npm run build
)和重新部署(firebase delpoy
)时,我的网站显示了一个 firebase 错误页面(在使用 ctrl+shift+r 更新缓存后,如此处建议)。经过长时间的检查,我意识到我应该向我的 firebase.json 添加重写,所以它看起来像这样:
{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [ {
"source": "**",
"destination": "/index.html"
} ]
},
"storage": {
"rules": "storage.rules"
}
}
我在构建项目时遇到了类似的问题,硬重置缓存并且没有任何效果。然后我意识到我前面有层 cloudflare cdn,它正在提供缓存数据。所以如果你前面有任何CDN,开发时禁用它。
另一种方法是删除 dist/<app_name> 文件夹并运行这些步骤,
我在使用 React App 时遇到了同样的问题。
Finally realised I hadn't run 'npm run build' therefore everything in the build folder had not been updated which is what Firebase was deploying.
I had a similar issue as well. I was using React.js to build a Covid Tracker, and I noticed a bug in my code. After fixing it, I was running firebase deploy
but it wasn't doing anything.
Long story short, you need to build the project before deploying it. Running npm run build
will create a new optimized version of your project, and then firebase deploy
will then go ahead and update your website.
尝试重新安装可能会很好firebase-tools
- 在遇到与您类似的问题后,我跑了npm i -g firebase-tools
,它似乎修复了它。
I also have the same issue with HUGO website hosting on firebase app.and the issue solved successfully,can be your reference.
firstly need delete the public file locally, can then re build site use
HUGO -D
now public file rebuilt.
then deploy again.
Firebase deploy
我认为为什么firebase没有更新是你只更新内容,但它不能自动更新公共文件,你需要重新重建公共文件。