问题描述
使用workbox-webpack-plugin
和InjectManifest时,您应该npm install
服务工作者中引用的所有依赖项吗?
例如(摘录自https://gist.github.com/jeffposnick/fc761c06856fa10dbf93e62ce7c4bd57):
import { CacheableResponsePlugin } from 'workbox-cacheable-response/CacheableResponsePlugin';
import { ExpirationPlugin } from 'workbox-expiration/ExpirationPlugin';
import { CacheFirst } from 'workbox-strategies/CacheFirst';
import { precacheAndRoute } from 'workbox-precaching/precacheAndRoute';
precacheAndRoute(self.__WB_MANIFEST);
registerRoute(
/^https:\/\/mylibrary\.io\/graphql\?.+cache%22:1/,new CacheFirst({
cacheName: 'short-cache',matchOptions: {
ignoreVary: true
},plugins: [
new ExpirationPlugin({
maxEntries: 500,maxAgeSeconds: 300,purgeOnQuotaError: true,}),new CacheableResponsePlugin({
statuses: [0,200]
}),]
}));
如果我可以运行npm install webpack-workbox-plugin --save-dev
而不必分别安装workbox-cacheable-response
,workbox-expiration
,workbox-strategies
和workbox-precaching
,以上方法将起作用,但这是正确的吗?
请注意,某些短毛猫(import/no-extraneous-dependencies
)也会将其标记为错误。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)