2019-07-03 14:50:04 +00:00
|
|
|
/* eslint-disable no-console */
|
|
|
|
|
2019-11-23 07:10:08 +00:00
|
|
|
import {register} from 'register-service-worker'
|
2019-07-03 14:50:04 +00:00
|
|
|
|
2021-02-07 19:02:33 +00:00
|
|
|
if (process.env.NODE_ENV === 'production' && window.location.protocol === "https:") {
|
|
|
|
|
2019-11-23 07:10:08 +00:00
|
|
|
register(`${process.env.BASE_URL}service-worker.js`, {
|
|
|
|
ready() {
|
2020-04-23 13:10:25 +00:00
|
|
|
console.log('App is being served from cache by a service worker.')
|
2019-11-23 07:10:08 +00:00
|
|
|
},
|
|
|
|
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() {
|
2020-02-23 05:42:50 +00:00
|
|
|
console.log('New content is available.');
|
|
|
|
window.location.reload();
|
2019-11-23 07:10:08 +00:00
|
|
|
},
|
|
|
|
offline() {
|
|
|
|
console.log('No internet connection found. App is running in offline mode.')
|
|
|
|
},
|
|
|
|
error(error) {
|
|
|
|
console.error('Error during service worker registration:', error)
|
|
|
|
}
|
|
|
|
})
|
2019-07-03 14:50:04 +00:00
|
|
|
}
|