From ebda5efe275154ca6015e665778a9f5c0678a6a8 Mon Sep 17 00:00:00 2001 From: yyh <92089059+lyzno1@users.noreply.github.com> Date: Thu, 5 Mar 2026 16:13:02 +0800 Subject: [PATCH] chore: prevent Storybook crash caused by vite-plugin-inspect (#33039) --- web/vite.config.ts | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/web/vite.config.ts b/web/vite.config.ts index b07e7ea7be..83a35f8558 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -160,6 +160,8 @@ if (import.meta.hot) { export default defineConfig(({ mode }) => { const isTest = mode === 'test' + const isStorybook = process.env.STORYBOOK === 'true' + || process.argv.some(arg => arg.toLowerCase().includes('storybook')) return { plugins: isTest @@ -176,14 +178,19 @@ export default defineConfig(({ mode }) => { }, } as Plugin, ] - : [ - Inspect(), - createCodeInspectorPlugin(), - createForceInspectorClientInjectionPlugin(), - react(), - vinext(), - customI18nHmrPlugin(), - ], + : isStorybook + ? [ + tsconfigPaths(), + react(), + ] + : [ + Inspect(), + createCodeInspectorPlugin(), + createForceInspectorClientInjectionPlugin(), + react(), + vinext(), + customI18nHmrPlugin(), + ], resolve: { alias: { '~@': __dirname, @@ -191,7 +198,7 @@ export default defineConfig(({ mode }) => { }, // vinext related config - ...(!isTest + ...(!isTest && !isStorybook ? { optimizeDeps: { exclude: ['nuqs'],