McNerdius / TailBlazor-Templates

.NET project templates for Blazor+Tailwind 3
https://templates.tailblazor.dev
BSD Zero Clause License
22 stars 2 forks source link

Hot reload not working when running in ASP.NET Core hosted mode #5

Open ErnieBernie10 opened 2 years ago

ErnieBernie10 commented 2 years ago

I was integrating a TailBlazor WASM template into my application. Noticed hot reload wasnt working when I launch it from a .Net Core hosted project that also contains the REST API. Only when I run the individual TailBlazor project does hot reload work.

McNerdius commented 2 years ago

Update: I assumed dotnet watch would be functionally equivalent to Ctrl+F5 / Start Without Debug. Nope.

With Ctrl+F5 i'm getting DOM updates and the Counter increment updates, but changes to the Weather Controller's values still aren't reflected.

I'll keep an eye on any changes in behavior as i do my tweaks to the hosted template and compare that to the blazorwasm single-project.



I haven't used hosted mode myself yet so i may be doing something wrong, but... Starting with a fresh default Hosted template, i couldn't get Hot Reload to work at all, from VS or CLI.

The edits i made all did the little checkmark indicator, but no functional difference was observed.  I had "Hot Reload on File Save" enabled but also did manual-hot-reloads via the button to no avail:

Setting Weather Summaries to include only "Scorching":

https://i.imgur.com/2zCi4TQ.gif

These others might not be as relevant but...

Editing `MainLayout.razor` didn't reflect the changes in the DOM, even after a manual refresh:

https://i.imgur.com/BenGE2T.gif

Editing the Counter increment also had no effect:

https://i.imgur.com/nsdsbXg.gif

---

I'll still put together an initial Tailwind-ized Hosted template this afternoon/tomorrow and do some reading on Hot Reload as it relates to Hosted projects but this initial experience has me scratching my head... Why *wouldn't* the default template be working ?  Surely i must be missing something lol.
ErnieBernie10 commented 2 years ago

I also did a lot of searching around and from what I read, hosted mode just doesn't work at all with hot reload so it's not really related to your tailwind integration.

As a workaround I am just launching the two hosts separately on separate ports, one for the UI and one for the API. After that, hot reloading does work. It's just a bit annoying. I think with later versions of hot reload this might get improved.

Though if you find a way to make it work that would be great and please reply in this thread about it.