Skip to content

PWA: integrate vite-plugin-pwa service worker #4

Description

@deanjstone

Add vite-plugin-pwa (new dependency — per map #1's decision) to apps/web/vite.config.ts, configure Workbox precaching for static assets, register the service worker in main.tsx.

Part of map #1.

Activity

  1. deanjstone commented on Jul 23, 2026

    @deanjstone
    OwnerAuthor

    Implemented via commit a0c8f15 on feature/pwa-web-app.

    Changes:

    • apps/web/package.json: added vite-plugin-pwa@^1.3.0 devDependency
    • apps/web/vite.config.ts: added VitePWA plugin with manifest: false (manifest.json stays hand-authored per PWA: add manifest.json and iOS meta tags #3), injectRegister: false, registerType: "autoUpdate", workbox.generateSW strategy, maximumFileSizeToCacheInBytes: 8 * 1024 * 1024 (default 2 MiB was too small for the editor bundle's main entry chunk)
    • apps/web/src/main.tsx: manual, Electron-guarded SW registration — navigator.serviceWorker.register("/sw.js") inside an else if ("serviceWorker" in navigator) branch alongside the existing isElectron check, since Electron loads this same bundle over a custom protocol (t3code://app/), not a real origin

    Why manual registration instead of the plugin's virtual:pwa-register helper: that virtual module failed to resolve workbox-window under this repo's rolldown-based vite-plus fork during production build, despite the package being correctly installed — a vite-plus/rolldown plugin-ecosystem gap, not a real missing dependency. Manual registration sidesteps the virtual module import entirely while still using generateSW for SW generation/precaching.

    Verification:

    • vp run --filter @t3tools/web build → succeeds, dist/sw.js generated with a 407-entry (17220.67 KiB) precache manifest
    • grep -c serviceWorker apps/web/dist/index.html → 0 (confirms no auto-injected registration script; it's fully manual)
    • vp run --filter @t3tools/web typecheck → clean
    • vp run --filter @t3tools/web test → 163 test files, 1438 tests, all passing

    Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    wayfinder:taskWayfinder: concrete build task

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions