Improve service worker (#1353)
* Improve service worker - Add new env variable in WebPack "NODE_ENV" - Add new service worker for mode dev that permit to by pass response in cache storage - Add new WorkAdventure icon * Remove console.log * Add service worker file prod and dev
This commit is contained in:
parent
1db2e2aba9
commit
22a46a98ea
11 changed files with 55 additions and 1 deletions
|
@ -17,6 +17,7 @@ const MAX_EXTRAPOLATION_TIME = 100; // Extrapolate a maximum of 250ms if no new
|
|||
export const MAX_USERNAME_LENGTH = parseInt(process.env.MAX_USERNAME_LENGTH || "") || 8;
|
||||
export const MAX_PER_GROUP = parseInt(process.env.MAX_PER_GROUP || "4");
|
||||
export const DISPLAY_TERMS_OF_USE = process.env.DISPLAY_TERMS_OF_USE == "true";
|
||||
export const NODE_ENV = process.env.NODE_ENV || "development";
|
||||
|
||||
export const isMobile = (): boolean => window.innerWidth <= 800 || window.innerHeight <= 600;
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { NODE_ENV } from "../Enum/EnvironmentVariable";
|
||||
|
||||
export class _ServiceWorker {
|
||||
constructor() {
|
||||
if ("serviceWorker" in navigator) {
|
||||
|
@ -6,8 +8,19 @@ export class _ServiceWorker {
|
|||
}
|
||||
|
||||
init() {
|
||||
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;
|
||||
}
|
||||
navigator.serviceWorker
|
||||
.register("/service-worker.js")
|
||||
.register("/service-worker-prod.js")
|
||||
.then((serviceWorker) => {
|
||||
console.info("Service Worker registered: ", serviceWorker);
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue