#8819·qwik

qwikVite: make Vite config the single source of truth for asset paths (stop overriding assetFileNames)

Author: maiieulCreated Jul 9, 2026Updated Sep 29, 2026
LabelsenhancementSSR

Problem

qwikVite overrides Rollup's output.assetFileNames (to assets/[hash]-[name]) in addition to forcing JS chunks into build/. Because it overrides asset paths, standard Vite options like build.assetsDir don't flow through the way users expect, and qwikVite has to special-case assetsDir itself.

That special-casing is applied client-only (useAssetsDir = target === 'client' in packages/qwik-vite/src/plugins/vite.ts). So with build.assetsDir set, the client and SSR builds disagree on the asset URL: the client chunk emits /q/… but the SSR-rendered HTML emits /assets/… while the file is actually at /q/… → 404 on first paint, before the client resumes.

Proposal — make Vite config the single source of truth

qwikVite should keep only its one real opinion — JS chunks live at build/ (the preloader's fixed home) — and otherwise read the Vite config instead of overriding paths:

  • Keep chunkFileNames / entryFileNames forced to build/… (with ??= so a user can still override).
  • Stop setting assetFileNames. Assets become 100% native Vite/Rolldown, so build.assetsDir (and base) just work — identically on client and SSR.

This is exactly how qwik-bundler already does it: src/build/chunking.ts's outputDefaults() sets only chunk/entry names, and assetFileNames / assetsDir appear nowhere in the source.

Evidence

Prototyped against current v2 qwikVite by deleting the assetFileNames override block. Emitted <img src> for a ?url asset:

config client src SSR src on disk chunks
default /assets/circle-…svg /assets/circle-…svg dist/assets/ dist/build
build.assetsDir: 'q' /q/circle-…svg /q/circle-…svg dist/q/ dist/build

build.assetsDir now relocates assets consistently on client + SSR — the 404 disappears, because it was caused purely by the client-only override. Users who want a nested assets/ subfolder can still set output.assetFileNames directly (native Rollup, no Qwik involvement).

The work

  1. Plugin: read the resolved Vite config as the source of truth — drop the assetFileNames override and the useAssetsDir / _astro special-case; keep chunks at build/.
  2. CLI: a create-qwik codemod to migrate any existing Qwik-specific options over to their regular Vite config keys, so current projects move over cleanly.

Scope / notes

  • Default asset filenames change from [hash]-[name] to Vite's native [name]-[hash] (cosmetic).
  • Router: with build.assetsDir natively relocating assets again, @qwik.dev/router needs to stay assetsDir-aware for isStaticPath and the Cloudflare _routes.json exclude — the direction of #8811, adjusted for the fact that chunks stay at build/ while assets move to <assetsDir>/.

Refs: #8811, #8817 (an initial attempt that instead removed build.assetsDir support while still overriding asset paths — wrong direction, superseded by this).