2018-05-18 11:28:29 +02:00
|
|
|
/* eslint-disable no-console */
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
import { register } from "register-service-worker";
|
2018-05-18 11:28:29 +02:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
if (process.env.NODE_ENV === "production") {
|
2018-05-18 11:28:29 +02:00
|
|
|
register(`${process.env.BASE_URL}service-worker.js`, {
|
|
|
|
ready() {
|
2020-02-18 08:57:00 +01:00
|
|
|
console.log(
|
|
|
|
"App is being served from cache by a service worker.\n" +
|
|
|
|
"For more details, visit https://goo.gl/AFskqB"
|
|
|
|
);
|
|
|
|
},
|
|
|
|
registered() {
|
|
|
|
console.log("Service worker has been registered.");
|
2018-05-18 11:28:29 +02:00
|
|
|
},
|
|
|
|
cached() {
|
2020-02-18 08:57:00 +01:00
|
|
|
console.log("Content has been cached for offline use.");
|
|
|
|
},
|
|
|
|
updatefound() {
|
|
|
|
console.log("New content is downloading.");
|
2018-05-18 11:28:29 +02:00
|
|
|
},
|
|
|
|
updated() {
|
2020-02-18 08:57:00 +01:00
|
|
|
console.log("New content is available; please refresh.");
|
2018-05-18 11:28:29 +02:00
|
|
|
},
|
|
|
|
offline() {
|
2020-02-18 08:57:00 +01:00
|
|
|
console.log("No internet connection found. App is running in offline mode.");
|
2018-05-18 11:28:29 +02:00
|
|
|
},
|
|
|
|
error(error) {
|
2020-02-18 08:57:00 +01:00
|
|
|
console.error("Error during service worker registration:", error);
|
2018-05-18 11:28:29 +02:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|