You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
985 B
31 lines
985 B
/* eslint-disable no-console */
|
|
|
|
import {register} from 'register-service-worker'
|
|
|
|
if (process.env.NODE_ENV === 'production' && window.location.protocol === "https:") {
|
|
|
|
register(`${process.env.BASE_URL}service-worker.js`, {
|
|
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() {
|
|
console.log('New content is available.');
|
|
window.location.reload();
|
|
},
|
|
offline() {
|
|
console.log('No internet connection found. App is running in offline mode.')
|
|
},
|
|
error(error) {
|
|
console.error('Error during service worker registration:', error)
|
|
}
|
|
})
|
|
}
|
|
|