Skip to content

SCSS file changes trigger full page reload instead of HMR #14869

Closed

Description

@aralroca

Astro Info

Astro                    v5.14.3
Vite                     v6.3.6
Node                     v22.14.0
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  @astrojs/node (v9.4.4)

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

Chrome

Describe the Bug

When modifying .scss files during development, Astro triggers a full page reload instead of hot module replacement (HMR). This disrupts the development workflow as it loses current state and scroll position.

If I write:

 if (import.meta.hot) {
     import.meta.hot.on('vite:beforeFullReload', (payload) => {
       console.log(payload);
     })
}

After save a .scss file, this log appears:

{type: 'full-reload'}

What's the expected result?

Changes to .scss files should trigger CSS-only hot updates without a full page reload.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-f9txtpa5?file=src%2Fcomponents%2FExample.module.scss

Participation

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

Activity

  1. id-87 commented on Nov 24, 2025

    @id-87

    @aralroca Please assign me this issue.

  2. aralroca commented on Nov 24, 2025

    @aralroca
    ContributorAuthor

    Of course, thanks @id-87

  3. aralroca commented on Nov 24, 2025

    @aralroca
    ContributorAuthor

    @id-87 I cannot assign you, probably some of the Astro maintainers can do it @matthewp @FredKSchott @natemoo-re

  4. danivicario commented on Nov 24, 2025

    @danivicario

    This is an important issue in the project I am working on, as this bogs you down a lot while implementing the figmas or experimenting.

    Thank you mr @aralroca for raising this, hoping the astro team kindly can solve this issue @id-87

    🙏

  5. florian-lefebvre commented on Nov 24, 2025

    @florian-lefebvre
    Member

    Interesting, the scss is correctly invalidated but then we actually force a full reload here: https://github.com/withastro/astro/blob/main/packages/astro/src/vite-plugin-hmr-reload/index.ts#L30. Probably need to fix the logic above

  6. added
    feat: styling
    - P3: minor bug
    feat: hmr
    and removed
    triage: needs triage
    on Nov 24, 2025
  7. aralroca commented on Nov 25, 2025

    @aralroca
    ContributorAuthor

    Interesting, the scss is correctly invalidated but then we actually force a full reload here: https://github.com/withastro/astro/blob/main/packages/astro/src/vite-plugin-hmr-reload/index.ts#L30. Probably need to fix the logic above

    It seems to come from somewhere else. I've added a similar plugin to Astro:

    https://stackblitz.com/edit/github-f9txtpa5?file=astro.config.mjs

    After saving the .scss file, hasSsrOnlyModules is false and modules is [].

  8. florian-lefebvre commented on Nov 25, 2025

    @florian-lefebvre
    Member

    I'm sure it comes from the place I linked as I tried it locally (at least with the provided minimal reproduction). Let's figure this out first and then we can look into other places where this could occur if the problem is still there

  9. ignacioroan commented on Nov 27, 2025

    @ignacioroan

    Have the same issue in my current project. Will be cool to have it solved, the page reload is a bit annoying :(

  10. aralroca commented on Nov 28, 2025

    @aralroca
    ContributorAuthor

    Adding

    if (clientModule.invalidationState === 'HARD_INVALIDATED') continue;

    Fixes the issue. No idea about this invalidationState, it's not typed in Astro but exists in the module. Any idea @florian-lefebvre ? Thanks

  11. florian-lefebvre commented on Nov 28, 2025

    @florian-lefebvre
    Member

    Not at all, I don't know this area well. Feel free to send a PR!

  12. added a commit that references this issue on Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

- P3: minor bugfeat: hmrfeat: styling

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions