如何在生产中为NUXT构建制作固定的文件名?
我正在使用docker容器内的NUXT和SSR。每当我构建生产项目时,它都会为js
文件块生成一些随机名称。由于浏览器的缓存,这会导致一些问题,该缓存试图加载未现有的JS文件。由于这些文件不再存在,因此我发现了许多在上一个部署中构建的JS文件中找不到的错误。
我如何解决这个问题?
I am using nuxt with SSR inside a Docker container. Whenever I build my project for production, it generates some random names for js
file chunks. This causes some issues because of the browser's cache, which tries to load not existing js files. Because these files no longer exist, I am getting a lot of not found
errors for js files built in the previous deployment.
How to can I deal with this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜您的浏览器缓存策略有问题,并且由于未找到/404状态代码问题不是常见的事情而无法正常工作。
为了回答您有关NUXT生产构建的固定块名称的问题,有一种内置方法可以使其正常工作,您可以通过遵循文档。
因此,要实现此目标,您可以在
nuxt.config.js
文件中进行此操作:I guess something wrong with your browser caching policy and it's not working as expected because the not found/404 status code issue is not a common thing.
In order to answer your question about the fixed chunk name for production build in Nuxt, there is a built-in method to make it work and you can learn that by following the documentation.
So to achieve this you do this in the
nuxt.config.js
file: