This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/registerServiceWorker.ts

34 lines
861 B
TypeScript
Raw Normal View History

2019-10-16 18:25:10 +00:00
/* eslint-disable no-console */
import {register} from 'register-service-worker'
2019-10-16 18:25:10 +00:00
if (import.meta.env.PROD) {
2022-02-15 12:07:34 +00:00
register('/sw.ts', {
ready() {
console.log('App is being served from cache by a service worker.')
},
registered() {
console.log('Service worker has been registered.')
},
cached() {
console.log('Content has been cached for offline use.')
},
updatefound() {
console.log('New content is downloading.')
},
updated(registration) {
console.log('New content is available; please refresh.')
// Send an event with the updated info
document.dispatchEvent(
new CustomEvent('swUpdated', {detail: registration}),
)
},
offline() {
console.log('No internet connection found. App is running in offline mode.')
},
error(error) {
console.error('Error during service worker registration:', error)
},
})
2019-10-16 18:25:10 +00:00
}