dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.75k stars 1.07k forks source link

Hot reload of scoped css in blazor not working for newly added css files #36333

Open vsfeedback opened 1 year ago

vsfeedback commented 1 year ago

This issue has been moved from a ticket on Developer Community.


[severity:It bothers me. A fix would be nice] When using dotnet watch run, hot reload does not work for scoped css files that have recently been added.

Every time I make a change in the scoped css file, the console tells me that "Hot reload of scoped css succeeded", but when inspecting in Chrome I loose all the styling that is in that css file. I have to rebuild (Ctrl+R) to get the styling back.

The element label/id [b-owbhi4vrwm] stays the same, but the problem seems to be that all the styling of the scoped css file disappears from the generated css file {ProjectName}.styles.css?nonce={some_kind_of_id}.

It seems like this appears whenever I add a new scoped css file. After restarting Visual Studio (Version 17.5.0 Preview 6.0) and restarting console with dotnet watch run (sdk 7.0.200-preview.22628.1) it seems to work again.


Original Comments

(no comments)


Original Solutions

(no solutions)

mkArtakMSFT commented 1 year ago

I was able to validate and confirm this. I've tried this on a Blazor WebAssembly Hosted app. While dotnet-watch was running, I've added a Counter.razor.css file and dotnet watch did detect a change. Then I've made some style changes to it and saved it, and dotnet watch noticed the change and written the following to the console:

Hot reload for scoped css succeeded.

However, the changes weren't showing up on the page. Changing style for an existing scoped css file worked as expected.

mkArtakMSFT commented 1 year ago

@SteveSandersonMS do you think this is something we control on our end when we actually apply CSS changes, or is this something inside dotnet-watch / hot reload logic that should be looked at? //cc @MackinnonBuck

SteveSandersonMS commented 1 year ago

I'm pretty sure this isn't an issue inside the browser-side logic that applies the changes, because it doesn't know anything about the original source files and which of them might be new.

It's much more likely to be inside watch or the IDE-side hot reload code since that does know about your source files on disk.

mkArtakMSFT commented 1 year ago

Thanks @SteveSandersonMS. @tmat reassigning back to you to investigate.

SteveSandersonMS commented 1 year ago

@tmat Would you mind moving this to a milestone so it no longer shows up in our triage query? Thanks!

BillHiebert commented 1 year ago

@mkArtakMSFT not sure why this is assigned to me. The scenario is with dotnet watch.

UltraWelfare commented 1 year ago

This happens to me as well using dotnet watch

jorge-teixeira commented 10 months ago

Same problem where dotnet watch