2019-07-03 14:50:04 +00:00
|
|
|
/* eslint-disable no-console */
|
|
|
|
|
2021-12-18 13:55:31 +00:00
|
|
|
import { register } from 'register-service-worker';
|
2019-07-03 14:50:04 +00:00
|
|
|
|
2021-12-18 13:55:31 +00:00
|
|
|
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);
|
|
|
|
},
|
|
|
|
});
|
2019-07-03 14:50:04 +00:00
|
|
|
}
|