Skip to content

fix(qwik-router): hot-reload CSS imported by route files#8725

Open
briancarbone wants to merge 1 commit into
QwikDev:build/v2from
briancarbone:fix/router-css-hmr
Open

fix(qwik-router): hot-reload CSS imported by route files#8725
briancarbone wants to merge 1 commit into
QwikDev:build/v2from
briancarbone:fix/router-css-hmr

Conversation

@briancarbone

Copy link
Copy Markdown

What is it?

  • Bug

Description

In dev, editing CSS imported by a route file (index.tsx / layout.tsx) had no effect. The dev server had to be restarted to see the change. CSS imported by a component updated instantly, as expected.

Qwik resolves these route CSS imports itself and injects them as tags, so the module only exists in the SSR module graph. Vite watches its own client module graph plus the route source-file globs, so it never watched these files, and a change fired no HMR event at all. Component CSS worked because Vite tracks and handles it natively.

The fix:

  • Register each injected CSS file with Vite's watcher so edits are seen.
  • On change, send a css-update to the client so Vite swaps the in place, matching native component CSS behavior.
  • CSS already in the client graph is left to Vite's native HMR, so component styling is untouched.

Scoped to route-injected CSS in dev mode. Production builds and component CSS are unaffected.

Checklist

  • My code follows the developer guidelines of this project
  • I performed a self-review of my own code
  • I added a changeset with pnpm change
  • I added new tests to cover the fix / functionality

Fixes #8724

CSS imported by route files (index/layout) is resolved by Qwik and
injected as a <link>, so it only lives in the SSR module graph. Vite
watches its own client graph plus the route source-file globs, never
this CSS, so edits produced no HMR event and styles stayed stale until a
dev server restart. CSS imported by client-loaded components was
unaffected because Vite handles those natively.

Register the injected CSS files with the watcher and, on change, emit a
css-update so Vite's client swaps the <link> in place. CSS already in
the client graph is left to Vite's native HMR.
@briancarbone briancarbone requested a review from a team as a code owner June 12, 2026 03:00
@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 73a6b5d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@qwik.dev/router Patch
eslint-plugin-qwik Patch
@qwik.dev/core Patch
create-qwik Patch
@qwik.dev/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@briancarbone briancarbone changed the title fix(router): hot-reload CSS imported by route files fix(qwik-router): hot-reload CSS imported by route files Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant