2018-05-18 09:28:29 +00:00
|
|
|
/* eslint-disable no-console */
|
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
import { register } from "register-service-worker";
|
2018-05-18 09:28:29 +00:00
|
|
|
|
2021-05-12 16:24:38 +00:00
|
|
|
if ("serviceWorker" in navigator && isProduction()) {
|
|
|
|
register(`${process.env.BASE_URL}service-worker.js`, {
|
|
|
|
ready() {
|
|
|
|
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.");
|
|
|
|
},
|
|
|
|
cached() {
|
|
|
|
console.log("Content has been cached for offline use.");
|
|
|
|
},
|
|
|
|
updatefound() {
|
|
|
|
console.log("New content is downloading.");
|
|
|
|
},
|
|
|
|
updated() {
|
|
|
|
console.log("New content is available; please refresh.");
|
|
|
|
},
|
|
|
|
offline() {
|
|
|
|
console.log(
|
|
|
|
"No internet connection found. App is running in offline mode."
|
|
|
|
);
|
|
|
|
},
|
|
|
|
error(error) {
|
|
|
|
console.error("Error during service worker registration:", error);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function isProduction(): boolean {
|
2021-06-01 16:08:03 +00:00
|
|
|
return true;
|
|
|
|
// return process.env.NODE_ENV === "production";
|
2021-05-12 16:24:38 +00:00
|
|
|
}
|