Skip to content

vite-plugin-pwa incompatible with tanstack start production builds #4988

Description

@f1shy-dev

Which project does this relate to?

Start

Describe the bug

vite-plugin-pwa's build steps (generate assets, generate serviceworker bundle) are seemingly not executed when running vite build with VitePWA() and tanstackStart() both present.

This is likely because to vite-plugin-pwa not having proper support for the Vite 6 environment API.
There is an open PR to solve this: vite-pwa/vite-plugin-pwa#786, however the current state of this PR has the same issue as the stable version of the package.

No PWA/SW steps are ran in build:

Image

but it works in the vite dev server:

Image

Your Example Website or App

https://stackblitz.com/edit/github-djpcrmc9?file=src%2Frouter.tsx

Steps to Reproduce the Bug or Issue

  1. npm install
  2. npm run build
  3. No PWA/SW steps are ran in build:

Expected behavior

  • Build steps actually run during vite build
  • Service worker gets built into tanstack start's client-dist, so it can also get picked up by nitro publicAssets[]
  • Any script injection steps such as into also work(?)

Screenshots or Videos

No response

Platform

  • Start Version: ^1.131.7
  • OS: macOS, Stackblitz WebContainer
  • Browser: Chrome
  • Browser Version: 139.0.7258.66
  • Bundler: Vite
  • Bundler Version: ^6.3.5

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions