76dd78130a
(cherry picked from commit cad5b4d7deba4fbe4a40a17306ce49d3b2f13139)
31 lines
887 B
JavaScript
31 lines
887 B
JavaScript
/* 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);
|
|
},
|
|
});
|
|
}
|