Skip to content

SCSS changes in imported file (in another SCSS file) aren't applied but still trigger hot reload #20198

Closed
@Novivy

Description

@Novivy

Describe the bug

If you do changes in a file that is imported in the styles.scss main file (that is itself imported to the main.js file), Vite will trigger a reload of the page but won't apply CSS changes.

If instead you import the file directly in main.js file, it will reload and apply changes correctly.

Reproduction

https://stackblitz.com/edit/vitejs-vite-dkrxb23v?file=src%2Fstyle.scss

Steps to reproduce

The stackblitz project does not work for some reason, but it you copy the files in local and do npm run dev, it will boot correctly.

  • Change background color of body in global.scss and save.

  • Vite will hot reload your page but won't apply the new color on the body. (in console it says 4:37:57 PM [vite] (client) hmr update /index.scss but seems to skip global.scss despite the change being made in it)

  • Stopping Vite and doing a new npm run dev will apply the new color.

  • If you import global.scss in main.js instead of importing it in styles.scss, it will make it work fine and apply the changes on each reload/change.

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (24) x64 AMD Ryzen 9 3900XT 12-Core Processor
    Memory: 24.21 GB / 63.91 GB
  Binaries:
    Node: 22.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.21 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.9.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.19041.5794
  npmPackages:
    @vitejs/plugin-react: ^4.5.1 => 4.5.1
    vite: ^6.3.5 => 6.3.5

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions