如何在Workbox + Vue cli3中启用在线模式?

时间:2018-08-15 18:04:14

标签: vue.js vuejs2 service-worker progressive-web-apps workbox

我想用service-workerWorkbox创建一个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();

0 个答案:

没有答案