Skip to content

fix(dev): keep a shared stylesheet in its first position - #431

Merged
ryansolid merged 1 commit into
nextfrom
fix/425-dev-shared-css-order
Oct 21, 2026
Merged

ryansolid merged 1 commit into
nextfrom
fix/425-dev-shared-css-order

Conversation

@lxsmnsyc

Copy link
Copy Markdown
Member

Fixes #425.

In start mode dev, a stylesheet shared by the entry graph and a lazy component now keeps its first position in <head>, as in production. Before, it moved after the lazy component's own styles, so equal-specificity overrides in the lazy component lost.

Changes

  • The dev shell renders the shared stylesheet twice. When both copies are server-rendered, the dev style patch now removes the later copy instead of the earlier one.
  • The patch now skips style tags that were already removed. Before, when both copies arrived in one mutation batch, the patch removed both of them.
  • When only one copy is server-rendered, the behavior is unchanged. That copy is removed and the tag Vite manages stays.

Testing

  • Added examples/start-ssr/test/style-patch.mjs. It runs the patch in jsdom for streamed copies, batched copies, and both orders of a server-rendered tag and a Vite tag.
  • The streamed and batched cases fail without the fix.
  • Reproduced the issue in headless Chrome with the files from the issue. After the fix, .corner resolves to position: absolute, and editing button.css still hot-updates it.
  • examples/start-ssr suite (node test/run.mjs) passes 749/749. pnpm test:unit passes.

🤖 Generated with Claude Code

In start mode dev, a stylesheet imported by both the entry graph and a
lazy component is rendered twice in the shell. When both copies were
server-rendered, the dev style patch removed the earlier one, so the
stylesheet moved after the lazy component's styles. The patch now
removes the later copy in that case, and skips tags that were already
removed.

Fixes #425

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b0887c0

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

This PR includes changesets to release 1 package
Name Type
@solidjs/vite-plugin 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

@pkg-pr-new

pkg-pr-new Bot commented Oct 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@solidjs/vite-plugin@431

commit: b0887c0

@ryansolid
ryansolid merged commit af73c98 into next Oct 21, 2026
6 checks passed
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.

2 participants