TanStack / TanStack/router

vite-plugin-pwa incompatible with tanstack start production builds

Open
#4,988 22 comments 32 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-upstream-fix
Dominant language
TypeScript
Stars
15.1k
Forks
1.9k
Avg merge
1d 20h
Merged PRs (30d)
143

Description

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: https://github.com/vite-pwa/vite-plugin-pwa/pull/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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked StackBlitz example, especially src/router.tsx, and run npm install followed by npm run build. Compare the VitePWA() and tanstackStart() build behavior under Vite 6, including the expected service worker output in client-dist and Nitro publicAssets[]. Done means the PWA build and injection steps run during vite build.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.