Browse Source

fix: remove navigator.serviceWorker redefinition in Vite config

The previous configuration attempted to redefine the read-only navigator.serviceWorker
property, which caused runtime errors. Instead, we now handle service worker
availability through the transform plugin, which safely removes service worker
code in Electron and PyWebView builds.

This fixes the error:
"Cannot set property serviceWorker of #<Navigator> which has only a getter"

Technical changes:
- Removed navigator.serviceWorker from define section
- Rely on existing transform plugin to handle service worker code removal
- Maintains existing PWA functionality for web builds while properly
  disabling it for desktop builds
pull/126/head
Matthew Raymer 1 week ago
parent
commit
fa15f7da85
  1. 3
      vite.config.mjs

3
vite.config.mjs

@ -60,9 +60,8 @@ export default defineConfig(({ mode }) => {
},
define: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'process.env.VITE_PWA_ENABLED': JSON.stringify(!isElectron),
'process.env.VITE_PWA_ENABLED': JSON.stringify(!(isElectron || isPyWebView)),
__dirname: isElectron ? JSON.stringify(process.cwd()) : '""',
'navigator.serviceWorker': isElectron ? 'undefined' : 'navigator.serviceWorker'
},
plugins: [
vue(),

Loading…
Cancel
Save