FitTrackee/fittrackee_client/src/registerServiceWorker.ts

35 lines
915 B
TypeScript
Raw Normal View History

/* eslint-disable no-console */
2021-07-25 13:23:25 +02:00
import { register } from 'register-service-worker'
2021-07-25 13:23:25 +02:00
if (process.env.NODE_ENV === 'production') {
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'
)
},
registered() {
2021-07-25 13:23:25 +02:00
console.log('Service worker has been registered.')
},
cached() {
2021-07-25 13:23:25 +02:00
console.log('Content has been cached for offline use.')
},
updatefound() {
2021-07-25 13:23:25 +02:00
console.log('New content is downloading.')
},
updated() {
2021-07-25 13:23:25 +02:00
console.log('New content is available; please refresh.')
},
offline() {
console.log(
2021-07-25 13:23:25 +02:00
'No internet connection found. App is running in offline mode.'
)
},
error(error) {
2021-07-25 13:23:25 +02:00
console.error('Error during service worker registration:', error)
},
2021-07-25 13:23:25 +02:00
})
}