jsakamoto / BlazingStory

The clone of "Storybook" for Blazor, a frontend workshop for building UI components and pages in isolation.
https://jsakamoto.github.io/BlazingStory/
Mozilla Public License 2.0
319 stars 16 forks source link

Dotnet Watch - Improvement #5

Open srpeirce opened 1 year ago

srpeirce commented 1 year ago

Hello,

I am trying this out today - I thought it would be great to quickly design some components with hot reload.

Problem

Hot reload works, but doesn't automatically update components in the story. To see updated component I need to refresh page, or swap to another story.

Recreate

dotnet new blazingstorywasm -n StoryWatch
cd .\StoryWatch\
dotnet watch

Then change the Button component somehow.


Would be possible to hot-reload inside each story (in the iframes)?

Thanks, Steve

jsakamoto commented 1 year ago

@srpeirce Thank you very much for your feedback! Yeah, I strongly agree with you.

Actually, I've mentioned the hot reloading in the FAQ section of the README as below:

Q1: Hot reloading and dotnet watch doesn't work. A1: Sorry for that. I want to manage to be available for hot reloading eventually.

It must be tough work, but I want to improve this part someday.

srpeirce commented 1 year ago

I think the problem is with the IFrame?

I took a bit more of a look last night and it seems to work if I load the IFrame URL directly in the browser.

I haven't looked further but hypothesis is that it's sime IFrame restrictions causing issues.

coryjthompson commented 10 months ago

@srpeirce is correct, the BrowserRefresh Middleware in the dotnet SDK will only inject aspnetcore-browser-refresh.js when the "Sec-Fetch-Dest" header is set to "document", which excludes iframes.

I've created a merge request (https://github.com/jsakamoto/BlazingStory/pull/20) to manually inject the script to the PreviewFrame's iframe.

jsakamoto commented 10 months ago

@coryjthompson Thank you for your pull request! I replied to you on theat pull request thread. https://github.com/jsakamoto/BlazingStory/pull/20#issuecomment-1890255139