From beda5138e018d9a853d57bd7274a35c21fa5c366 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Fri, 19 Aug 2022 21:23:31 +0200 Subject: fix(frontend): destroy service worker in dev mode If the application is run in both production and development mode on the same domain, make sure to clean up the production service worker. --- subprojects/frontend/vite.config.ts | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'subprojects/frontend/vite.config.ts') diff --git a/subprojects/frontend/vite.config.ts b/subprojects/frontend/vite.config.ts index 7c0c2605..bb421788 100644 --- a/subprojects/frontend/vite.config.ts +++ b/subprojects/frontend/vite.config.ts @@ -66,6 +66,12 @@ export default defineConfig({ strategies: 'generateSW', registerType: 'prompt', injectRegister: null, + devOptions: { + enabled: true, + }, + // Unregister service worker installed in production mode + // if Vite is started in development mode on the same domain. + selfDestroying: isDevelopment, workbox: { globPatterns: [ '**/*.{css,html,js}', @@ -74,6 +80,7 @@ export default defineConfig({ ], dontCacheBustURLsMatching: /\.(?:css|js|woff2?)$/, navigateFallbackDenylist: [/^\/xtext-service/], + sourcemap: isDevelopment, }, includeAssets: ['apple-touch-icon.png', 'favicon.svg', 'mask-icon.svg'], manifest: { -- cgit v1.2.3-70-g09d2