rollup-plugin-svelte-hot icon indicating copy to clipboard operation
rollup-plugin-svelte-hot copied to clipboard

Imported CSS not updating

Open mightyplow opened this issue 4 years ago • 4 comments

Hi,

I don't know exactly whether this is the correct project to create the issue but I'll try at least.

I have an App component which has a style tag with a the global attribute enabled and the lang attribute set to postcss. All it does is calling an @import statement to include some basic css. This for itself works just fine.

When I change something in the base css file, the browser console tells me, that the bundle is getting rebuilt but afterwards it says that there were no changes.

I ended up importing the css file in the script tag and add the postcss plugin to the rollup config but this has other issues. I definitly would prefer the first solution if that is somehow posible.

Does anyone have a clue on how to solve this?

mightyplow avatar Jan 19 '21 20:01 mightyplow

Hi! Thanks for reporting.

Are you using rollup-plugin-hot? Nollup? Vite?

Could you paste the exact output in the browser console, and in the term, after the sequence of events you've described?

Also, if you could share your project, or a similar setup, it could speed up reproduction & resolution.

rixo avatar Jan 20 '21 16:01 rixo

Hi @rixo,

thanks you for taking care of this!

I created a basic example here. You just have to install the dependencies and run npm start (python 3 required). It then starts the server on port 8080.

The exact output in the browser console after I change something in the styles.css file is

[HMR] Connected
index.js:15 [HMR] Rebuilding...
index.js:15 [HMR] Nothing changed

mightyplow avatar Jan 20 '21 17:01 mightyplow

OK thanks. So this is a bug in rollup-plugin-hot not accounting for the fact that a file may have not changed itself but still is "dirty" because an "external" (i.e. the SCSS @import, as opposed to a normal ES import) dep has changed.

Ideally the Svelte plugin should report those dependencies to Rollup and an automatic fix could be done. Need to check this. Otherwise maybe I can just add an option to rollup-plugin-hot to notify the change even if the file seems unmodified.

rixo avatar Jan 20 '21 17:01 rixo

This would be really cool. I already tried to debug the whole process a bit but I did not know where to actually look at. But sounds like this would be fixible. Glad to hear!

mightyplow avatar Jan 20 '21 19:01 mightyplow