Caching service workera

This commit is contained in:
2022-07-14 17:50:17 +02:00
parent 4ca1c7bb9c
commit 55c64d5f0a
2 changed files with 15 additions and 10 deletions
+7 -10
View File
@@ -5,28 +5,25 @@ import { register } from 'register-service-worker'
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
register(`${process.env.BASE_URL}service-worker.js`, { register(`${process.env.BASE_URL}service-worker.js`, {
ready () { ready () {
console.log( console.log('SW gotowy')
'App is being served from cache by a service worker.\n' +
'For more details, visit https://goo.gl/AFskqB'
)
}, },
registered () { registered () {
console.log('Service worker has been registered.') console.log('SW: zarejestrowano')
}, },
cached () { cached () {
console.log('Content has been cached for offline use.') console.log('SW: cached')
}, },
updatefound () { updatefound () {
console.log('New content is downloading.') console.log('SW: aktualizacja danych')
}, },
updated () { updated () {
console.log('New content is available; please refresh.') console.log('SW: zaktualizowano dane');
}, },
offline () { offline () {
console.log('No internet connection found. App is running in offline mode.') console.log('SW: tryb offline')
}, },
error (error) { error (error) {
console.error('Error during service worker registration:', error) console.error('SW: wystąpił błąd - ', error)
} }
}) })
} }
+8
View File
@@ -0,0 +1,8 @@
module.exports = {
pwa: {
workboxOptions: {
skipWaiting: true,
clientsClaim: true,
},
},
};