-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[Bug]: HMR of preview.tsx
is not working
#26881
Comments
Currently, as a countermeasure, I am using a plugin called import type { StorybookConfig } from "@storybook/react-vite"
import { InlineConfig, UserConfig, mergeConfig } from "vite"
import path, { dirname, join } from "path"
const config: StorybookConfig = {
framework: getAbsolutePath("@storybook/react-vite"),
core: {
disableTelemetry: true,
},
stories: ["../stories/**/*.@(mdx|stories.@(tsx))"],
addons: [
getAbsolutePath("@storybook/addon-viewport"),
getAbsolutePath("@storybook/addon-docs"),
getAbsolutePath("@storybook/addon-a11y"),
getAbsolutePath("@storybook/addon-backgrounds"),
getAbsolutePath("@storybook/addon-measure"),
getAbsolutePath("@storybook/addon-storysource"),
getAbsolutePath("storybook-dark-mode"),
],
viteFinal: async (config) => {
config = mergeConfig<InlineConfig, UserConfig>(config, {
+ plugins: [
+ {
+ name: "force-reload-on-specific-files",
+ handleHotUpdate: ({ file, server }) => {
+ const isTheme = file.startsWith(
+ path.resolve(__dirname, "../packages/theme/src"),
+ )
+ const isProviders = file.startsWith(
+ path.resolve(__dirname, "../packages/providers/src"),
+ )
+
+ if (isTheme || isProviders) {
+ server.hot.send({ type: "full-reload" })
+ }
+ },
+ },
+ ],
resolve: {
alias: [
{
find: /\@yamada-ui\/react$/,
replacement: path.resolve(__dirname, "../packages/react/src"),
},
{
find: /\@yamada-ui\/theme$/,
replacement: path.resolve(__dirname, "../packages/theme/src"),
},
],
},
})
config.esbuild = undefined
return config
},
typescript: {
reactDocgen: false,
},
}
export default config
function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, "package.json")))
} |
Thanks @hirotomoyamada, |
I am able to reproduce this in a new Vite project. In my case, I added & removed the following to the parameters:
Manually refreshing the page fixes it, but obvs that's not HMR. @joshwooding I bet fixing this will also resolve your issue with docgen updates not refreshing the ArgsTable. @valentinpalkovic @vanessayuenn Unless there are burning fires, this would get my vote as top priority for empathy week. |
Describe the bug
After upgrading to v8, HMR no longer works for
preview.tsx
.To Reproduce
preview.tsx
components.tsx
Until v7, updating the
StoryProvider
in thedecorators
, i.e.UIProvider
, made HMR work.System
Additional context
No response
The text was updated successfully, but these errors were encountered: