sveltejs / svelte-preprocess

A ✨ magical ✨ Svelte preprocessor with sensible defaults and support for: PostCSS, SCSS, Less, Stylus, Coffeescript, TypeScript, Pug and much more.
MIT License
1.73k stars 147 forks source link

If style block has `global` attribute, reverted styles don't update until page refresh #573

Open JohnnyFun opened 1 year ago

JohnnyFun commented 1 year ago

Describe the bug

In my svelte.config.js, I'm using globalStyle. If I make a css change to a style tag with a global attribute, the app updates via HMR as expected, but if I revert the change, the app doesn't re-update to show the initial styling.

To Reproduce Repro: https://github.com/JohnnyFun/svelte-preprocess-issue-global

Information about your project: (output of npx webpack-cli info

System:
    OS: Windows 10 10.0.22621
    CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
    Memory: 11.61 GB / 31.95 GB
  Binaries:
    Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
    npm: 8.8.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 109.0.5414.120
  Packages:
    css-loader: ^6.7.3 => 6.7.3 
    svelte-loader: ^3.0.0 => 3.1.5 
    webpack: ^5.16.0 => 5.75.0 
    webpack-cli: ^5.0.1 => 5.0.1 
    webpack-dev-server: ^4.11.1 => 4.11.1 
JohnnyFun commented 1 year ago

This might actually be an issue at the svelte-loader level. Looks like it happens if I explicitly use :global too and get rid of the global style attribute.