make8bitart.com
at main 46 lines 1.5 kB view raw
1/* 2 * ServiceWorker to make site function as a PWA (Progressive Web App) 3 * 4 * Based on https://glitch.com/~pwa by https://glitch.com/@PaulKinlan 5 */ 6 7// Specify what we want added to the cache for offline use 8self.addEventListener("install", (e) => { 9 e.waitUntil( 10 // Give the cache a name 11 caches.open("make8bitart-pwa").then((cache) => { 12 // Cache the homepage and stylesheets - add any assets you want to cache! 13 return cache.addAll([ 14 "/", 15 "/index.html", 16 "/app.min.js", 17 "/make8bitart.min.css", 18 "/assets/bg.png", 19 "/assets/brighton.png", 20 "/assets/hsl-palette.png", 21 "/assets/example.csv", 22 "/assets/draggydivs/dragger.png", 23 "/assets/draggydivs/hider.png", 24 "/assets/icons/copy.png", 25 "/assets/icons/cut.png", 26 "/assets/icons/dropper.png", 27 "/assets/icons/paint.png", 28 "/assets/icons/paste-disabled.png", 29 "/assets/icons/paste.png", 30 "/assets/icons/pencil.png", 31 "/assets/fonts/8bit-Art-Sans-subset.woff2", 32 "/assets/fonts/VT323-Regular-subset.woff2", 33 ]); 34 }) 35 ); 36}); 37 38// Network falling back to cache approach - we only cache the home route 39// https://developers.google.com/web/ilt/pwa/caching-files-with-service-worker 40self.addEventListener("fetch", function (event) { 41 event.respondWith( 42 fetch(event.request).catch(function () { 43 return caches.match(event.request); 44 }) 45 ); 46});