-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide an option to exclude files from HMR #321
Comments
As far as i am aware storybook is not going to support authoring stories in svelte format going forward, and focuses on their own component story format (csf) instead. So i'm not really sure how csf stories would end up being processed by vite-plugin-svelte. As a workaround you could create 2 instances of vite-plugin-svelte that operate on disjunct sets with include/exclude: const storyPattern = "**/*.story.svelte";
export default {
plugins:[
svelte({exclude: storyPattern}),
{
...svelte({include: storyPattern, hot: false}),
name: "vite-plugin-svelte-stories" // avoid 2 plugin instances with same name
}
]
} |
Thanks for the workaround suggestion. That looks like it will work. It sounds like it's a bit uncertain what will happen in storybook 7.0, but I want to make sure everything works correctly in 6.x. |
If the workaround works, I think it is the solution instead of adding another option for this case, as |
Fixes #52 Svelte story files have the same issue as react story files. The webpack HMR seems to prevent vite's HMR from working correctly, so we need to exclude story files as HMR boundaries in vite. The svelte plugin doesn't expose as nice of a way to do this, but thanks to a suggestion from @domyen in sveltejs/vite-plugin-svelte#321 (comment), I was able to make it work. To test: Start up the svelte example, edit a `.stories.svelte` file, and confirm that the page reloads and shows your changes.
Describe the problem
In the storybook vite builder, we have a problem with svelte stories not correctly reloading when changes are made to files. I don't completely understand what's going on, but story files are watched by the manager webpack so that it can HMR the list of files, but that makes them incompatible for vite HMR, it seems. We had the same problem with react stories, and the solution was to exclude stories from HMR, allowing the page to reload instead when changes are made.
However, it seems there's no such option for svelte to control when HMR happens. It's only on or off, as far as I can tell.
Describe the proposed solution
It would be great if you could support an
include/exclude
set of globs, much like rollup transform plugins or @vitejs/plugin-react: https://github.com/vitejs/vite/tree/main/packages/plugin-react#filter-which-files-use-fast-refreshAlternatives considered
I can turn off HMR entirely for svelte projects, but that doesn't seem like a great option. HMR is working just fine when editing components, just not stories.
Importance
would make
my lifethe life of storybook users easierThe text was updated successfully, but these errors were encountered: