diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-08-19 21:23:31 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-08-20 21:41:50 +0200 |
commit | beda5138e018d9a853d57bd7274a35c21fa5c366 (patch) | |
tree | 3f6ff98c917db824a850c85eee7fbd76021adc27 /subprojects/frontend/vite.config.ts | |
parent | feat(frontend): add PWA manifest (diff) | |
download | refinery-beda5138e018d9a853d57bd7274a35c21fa5c366.tar.gz refinery-beda5138e018d9a853d57bd7274a35c21fa5c366.tar.zst refinery-beda5138e018d9a853d57bd7274a35c21fa5c366.zip |
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.
Diffstat (limited to 'subprojects/frontend/vite.config.ts')
-rw-r--r-- | subprojects/frontend/vite.config.ts | 7 |
1 files changed, 7 insertions, 0 deletions
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({ | |||
66 | strategies: 'generateSW', | 66 | strategies: 'generateSW', |
67 | registerType: 'prompt', | 67 | registerType: 'prompt', |
68 | injectRegister: null, | 68 | injectRegister: null, |
69 | devOptions: { | ||
70 | enabled: true, | ||
71 | }, | ||
72 | // Unregister service worker installed in production mode | ||
73 | // if Vite is started in development mode on the same domain. | ||
74 | selfDestroying: isDevelopment, | ||
69 | workbox: { | 75 | workbox: { |
70 | globPatterns: [ | 76 | globPatterns: [ |
71 | '**/*.{css,html,js}', | 77 | '**/*.{css,html,js}', |
@@ -74,6 +80,7 @@ export default defineConfig({ | |||
74 | ], | 80 | ], |
75 | dontCacheBustURLsMatching: /\.(?:css|js|woff2?)$/, | 81 | dontCacheBustURLsMatching: /\.(?:css|js|woff2?)$/, |
76 | navigateFallbackDenylist: [/^\/xtext-service/], | 82 | navigateFallbackDenylist: [/^\/xtext-service/], |
83 | sourcemap: isDevelopment, | ||
77 | }, | 84 | }, |
78 | includeAssets: ['apple-touch-icon.png', 'favicon.svg', 'mask-icon.svg'], | 85 | includeAssets: ['apple-touch-icon.png', 'favicon.svg', 'mask-icon.svg'], |
79 | manifest: { | 86 | manifest: { |