Skip to content

HMR of CSS doesn't work for previously non-styled elements #15384

@illright

Description

@illright

Astro Info

Astro                    v6.0.0-beta.6
Vite                     v7.3.1
Node                     v25.3.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When a new CSS ruleset (selector + styles) is added to the code targeting an element that hasn't been styled before, the HMR doesn't seem to pick it up, and it requires a server restart to get the styles to appear.

What's the expected result?

I expect HMR to update the styles regardless of whether it's a new element being targeted or one that already has styles.

Link to Minimal Reproducible Example

https://stackblitz.com/~/github.com/illright/astro-v6-hmr-repro

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P4: importantViolate documented behavior or significantly impacts performance (priority)6-betaIssues affects the beta of Astro 6feat: hmrRelated to HMR (scope)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions