From 018b93aaa6beb860d502f1a58e194415502a73ff Mon Sep 17 00:00:00 2001 From: Patryk Andrzejewski Date: Tue, 6 Dec 2022 11:12:19 +0100 Subject: [PATCH] Prevent infinite reloading service worker (#2785) * Respect interval for service worker * Do not load sw by vie plugin * Move comment above --- src/config.ts | 2 +- vite.config.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 7f4381fe5..7d8a3502d 100644 --- a/src/config.ts +++ b/src/config.ts @@ -6,7 +6,7 @@ export const getAppDefaultUri = () => "/"; export const getAppMountUri = () => window.__SALEOR_CONFIG__.APP_MOUNT_URI || getAppDefaultUri(); export const getApiUrl = () => window.__SALEOR_CONFIG__.API_URL; -export const SW_INTERVAL = parseInt(process.env.SW_INTERVAL, 10); +export const SW_INTERVAL = parseInt(process.env.SW_INTERVAL, 10) || 300; export const IS_CLOUD_INSTANCE = process.env.IS_CLOUD_INSTANCE === "true"; export const MARKETPLACE_URL = window.__SALEOR_CONFIG__.MARKETPLACE_URL; export const MARKETPLACE_SALEOR_APPS_PAGE_PATH = diff --git a/vite.config.js b/vite.config.js index 51f9a0448..26a06575b 100644 --- a/vite.config.js +++ b/vite.config.js @@ -70,6 +70,10 @@ export default defineConfig(({ command, mode }) => { plugins.push( VitePWA({ + /* + We use 'register-service-worker' for registering sw.js. + */ + injectRegister: null, strategies: "injectManifest", /*