This commit is contained in:
Tixie 2021-10-15 18:25:12 +02:00
parent 2c69a199ee
commit 74f3df8c01
2 changed files with 3 additions and 3 deletions

View file

@ -3,7 +3,7 @@ import store from '~/src/store'
export default () => { export default () => {
if ('serviceWorker' in navigator && process.env.NODE_ENV === 'production') { if ('serviceWorker' in navigator && process.env.NODE_ENV === 'production') {
navigator.serviceWorker navigator.serviceWorker
.register(new URL('~/src/service-worker.js', import.meta.url), {type: 'module'}) .register(new URL('~/src/service-worker.js', import.meta.url), { type: 'module' })
.then(registration => { .then(registration => {
registration.onupdatefound = () => { registration.onupdatefound = () => {
const installingWorker = registration.installing const installingWorker = registration.installing

View file

@ -1,13 +1,13 @@
import { manifest, version } from '@parcel/service-worker' import { manifest, version } from '@parcel/service-worker'
async function install() { async function install () {
const cache = await caches.open(version) const cache = await caches.open(version)
await cache.addAll(manifest) await cache.addAll(manifest)
} }
addEventListener('install', e => e.waitUntil(install())) addEventListener('install', e => e.waitUntil(install()))
async function activate() { async function activate () {
const keys = await caches.keys() const keys = await caches.keys()
await Promise.all( await Promise.all(