Fix PWA service worker

This commit is contained in:
grandeljay 2022-07-07 13:53:41 +02:00
parent ffead11335
commit 3eeb808482
2 changed files with 41 additions and 5 deletions

View file

@ -4,9 +4,9 @@
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker
.register('/serviceWorker.js')
.then(res => console.log('service worker registered'))
.catch(err => console.log('service worker not registered', err))
.register('/src/assets/js/service-worker.js')
.then(res => console.log('wishthis service worker registered'))
.catch(err => console.log('wishthis service worker not registered', err))
})
}

View file

@ -1,12 +1,48 @@
const staticDevCoffee = 'wishthis'
const assets = [
'/'
'/src/assets/css/default/dark.css',
'/src/assets/css/blog.css',
'/src/assets/css/default.css',
'/src/assets/css/home.css',
'/src/assets/css/post.css',
'/src/assets/css/wishlists-saved.css',
'/src/assets/css/wishlists.css',
'/src/assets/img/favicon/android-chrome-192x192.png',
'/src/assets/img/favicon/android-chrome-512x512.png',
'/src/assets/img/favicon/apple-touch-icon.png',
'/src/assets/img/favicon/favicon-16x16.png',
'/src/assets/img/favicon/favicon-32x32.png',
'/src/assets/img/favicon/favicon.ico',
'/src/assets/img/favicon/mstile-70x70.png',
'/src/assets/img/favicon/mstile-150x150.png',
'/src/assets/img/favicon/mstile-310x150.png',
'/src/assets/img/favicon.png',
'/src/assets/img/favicon.svg',
'/src/assets/img/logo-animation.svg',
'/src/assets/img/logo-square-white-background.png',
'/src/assets/img/logo-square-white-background.svg',
'/src/assets/img/logo-square.png',
'/src/assets/img/logo-square.svg',
'/src/assets/img/logo.svg',
'/src/assets/img/no-image.svg',
'/src/assets/js/parts/wishlist-filter.js',
'/src/assets/js/changelog.js',
'/src/assets/js/default.js',
'/src/assets/js/home.js',
'/src/assets/js/login-as.js',
'/src/assets/js/profile.js',
'/src/assets/js/register.js',
'/src/assets/js/service-worker.js',
'/src/assets/js/wishlist.js',
'/src/assets/js/wishlists.js',
]
self.addEventListener('install', installEvent => {
installEvent.waitUntil(
caches.open(staticDevCoffee).then(cache => {
cache.addAll(assets)
cache.addAll(assets)
})
)
})