2021-08-10 22:34:46 +02:00
|
|
|
import { NODE_ENV } from "../Enum/EnvironmentVariable";
|
|
|
|
|
2021-07-29 16:42:31 +02:00
|
|
|
export class _ServiceWorker {
|
|
|
|
constructor() {
|
|
|
|
if ("serviceWorker" in navigator) {
|
|
|
|
this.init();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
init() {
|
2021-08-10 22:34:46 +02:00
|
|
|
if (NODE_ENV === "development") {
|
|
|
|
navigator.serviceWorker
|
|
|
|
.register("/service-worker-dev.js")
|
|
|
|
.then((serviceWorker) => {
|
|
|
|
console.info("Service Worker registered: ", serviceWorker);
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error("Error registering the Service Worker: ", error);
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
2021-08-04 13:33:58 +02:00
|
|
|
navigator.serviceWorker
|
2021-08-10 22:34:46 +02:00
|
|
|
.register("/service-worker-prod.js")
|
2021-08-04 13:33:58 +02:00
|
|
|
.then((serviceWorker) => {
|
|
|
|
console.info("Service Worker registered: ", serviceWorker);
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error("Error registering the Service Worker: ", error);
|
|
|
|
});
|
2021-07-29 16:42:31 +02:00
|
|
|
}
|
|
|
|
}
|