Description
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 skipglobal.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
inmain.js
instead of importing it instyles.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
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.