2021-07-24 20:56:37 +02:00
|
|
|
/* eslint-disable no-console */
|
|
|
|
|
2021-07-25 13:23:25 +02:00
|
|
|
import { register } from 'register-service-worker'
|
2021-07-24 20:56:37 +02:00
|
|
|
|
2021-07-25 13:23:25 +02:00
|
|
|
if (process.env.NODE_ENV === 'production') {
|
2021-07-24 20:56:37 +02:00
|
|
|
register(`${process.env.BASE_URL}service-worker.js`, {
|
|
|
|
ready() {
|
|
|
|
console.log(
|
2021-07-25 13:23:25 +02:00
|
|
|
'App is being served from cache by a service worker.\n' +
|
|
|
|
'For more details, visit https://goo.gl/AFskqB'
|
|
|
|
)
|
2021-07-24 20:56:37 +02:00
|
|
|
},
|
|
|
|
registered() {
|
2021-07-25 13:23:25 +02:00
|
|
|
console.log('Service worker has been registered.')
|
2021-07-24 20:56:37 +02:00
|
|
|
},
|
|
|
|
cached() {
|
2021-07-25 13:23:25 +02:00
|
|
|
console.log('Content has been cached for offline use.')
|
2021-07-24 20:56:37 +02:00
|
|
|
},
|
|
|
|
updatefound() {
|
2021-07-25 13:23:25 +02:00
|
|
|
console.log('New content is downloading.')
|
2021-07-24 20:56:37 +02:00
|
|
|
},
|
|
|
|
updated() {
|
2021-07-25 13:23:25 +02:00
|
|
|
console.log('New content is available; please refresh.')
|
2021-07-24 20:56:37 +02:00
|
|
|
},
|
|
|
|
offline() {
|
|
|
|
console.log(
|
2021-07-25 13:23:25 +02:00
|
|
|
'No internet connection found. App is running in offline mode.'
|
|
|
|
)
|
2021-07-24 20:56:37 +02:00
|
|
|
},
|
|
|
|
error(error) {
|
2021-07-25 13:23:25 +02:00
|
|
|
console.error('Error during service worker registration:', error)
|
2021-07-24 20:56:37 +02:00
|
|
|
},
|
2021-07-25 13:23:25 +02:00
|
|
|
})
|
2021-07-24 20:56:37 +02:00
|
|
|
}
|