工作箱:构建项目时无法缓存所有文件 [英] Workbox: cannot cache all files when build project

查看:70
本文介绍了工作箱:构建项目时无法缓存所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Vuejs ,并且使用 workbox-webpack-plugin 来使网站脱机,我想缓存一个包含我所有文件的文件夹(3个文件),就像下面的图片一样,但是当我构建项目时(使用 Laravel-mix ). main.js (包含Vue的所有内容)无法缓存在 service-woker.js 中.我尝试了一些方法来解决此问题,但这些方法无效.有人面对这个问题吗,您有任何解决方案吗,非常感谢!

I use Vuejs and I use workbox-webpack-plugin in order to make my site offline, I want to cache a folder which contains all my files (3 files) like picture below, but when I build my project(using Laravel-mix). The main.js (which contains everything of Vue) cannot be cached in service-woker.js. I tried some ways to fix that but those didn't work. Does anybody face this issue, do you have any solution, many thanks!

->>

推荐答案

好久没有回头看这个问题了,github 上的一个人帮我找出了原因.

After a longtime haven't looked back this issue, there's a guy on github helped me find out why.

这是因为库调用中有一个属性 maximumFileSizeToCacheInBytes 默认设置为 2MB,这意味着它只会缓存小于或等于 2MB 的文件,而我构建的一些文件则大于该值.因此,您只需增加 maximumFileSizeToCacheInBytes 即可解决此问题.

It's because there's a property in the library call maximumFileSizeToCacheInBytes is set default to 2MB, that means it will only cache files which in smaller or equal 2MB, while some of my built files are larger than that. So you just need to increase maximumFileSizeToCacheInBytes do solve this issue.

这篇关于工作箱:构建项目时无法缓存所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆