/* * ServiceWorker to make site function as a PWA (Progressive Web App) * * Based on https://glitch.com/~pwa by https://glitch.com/@PaulKinlan */ // Specify what we want added to the cache for offline use self.addEventListener("install", (e) => { e.waitUntil( // Give the cache a name caches.open("make8bitart-pwa").then((cache) => { // Cache the homepage and stylesheets - add any assets you want to cache! return cache.addAll([ "/", "/index.html", "/app.min.js", "/make8bitart.min.css", "/assets/bg.png", "/assets/brighton.png", "/assets/hsl-palette.png", "/assets/example.csv", "/assets/draggydivs/dragger.png", "/assets/draggydivs/hider.png", "/assets/icons/copy.png", "/assets/icons/cut.png", "/assets/icons/dropper.png", "/assets/icons/paint.png", "/assets/icons/paste-disabled.png", "/assets/icons/paste.png", "/assets/icons/pencil.png", "/assets/fonts/8bit-Art-Sans-subset.woff2", "/assets/fonts/VT323-Regular-subset.woff2", ]); }) ); }); // Network falling back to cache approach - we only cache the home route // https://developers.google.com/web/ilt/pwa/caching-files-with-service-worker self.addEventListener("fetch", function (event) { event.respondWith( fetch(event.request).catch(function () { return caches.match(event.request); }) ); });