我想用service-worker
为Workbox
创建一个Pwa
。
我创建了此脚本,但无法正常工作。
(service-worker
在工作)
workbox-config.js:
module.exports = {
"globDirectory": "dist/",
"globPatterns": [
"**/*.{css,png,svg,html,js,json}"
],
"swDest": "dist\\sw.js",
"swSrc": "src/src-sw.js",
// Increase the limit to 4mb:
maximumFileSizeToCacheInBytes: 4 * 1024 * 1024
}
src-sw.js:
importScripts('https://storage.googleapis.com/workbox-
cdn/releases/3.0.0/workbox-sw.js');
console.log('this is my custom service worker');
self.__precacheManifest = [].concat(self.__precacheManifest || [])
workbox.precaching.suppressWarnings()
workbox.precaching.precacheAndRoute([]);
workbox.precaching.addRoute();