@@ -19,27 +19,25 @@ const config: StorybookConfig = {
1919 "options" : { }
2020 } ,
2121 async viteFinal ( config : UserConfig ) {
22- // Filter out Storybook's default React plugin
22+ // Remove any existing Vite React plugins that Storybook registers
2323 config . plugins = ( config . plugins || [ ] ) . filter ( ( plugin ) => {
24- return ! (
25- Array . isArray ( plugin ) &&
26- plugin [ 0 ] ?. name ?. includes ( 'vite:react' )
27- ) ;
24+ if ( ! plugin ) return true ;
25+ const pluginName = Array . isArray ( plugin ) ? plugin [ 0 ] ?. name : plugin . name ;
26+ return ! pluginName ?. includes ( 'vite:react' ) ;
2827 } ) ;
2928
30- // Add React plugin with emotion configuration
31- // Force Babel to process all files (not just JSX) to ensure emotion transforms work
29+ // Re-register the React plugin with Emotion configuration
3230 config . plugins . push (
3331 react ( {
34- include : '**/*.{jsx,tsx,ts,js}' ,
32+ exclude : [ / \. s t o r i e s \. ( t | j ) s x ? $ / , / n o d e _ m o d u l e s / ] ,
3533 jsxImportSource : '@emotion/react' ,
3634 babel : {
3735 plugins : [ '@emotion/babel-plugin' ] ,
3836 } ,
3937 } )
4038 ) ;
4139
42- // Optimize emotion dependencies
40+ // Pre-bundle Emotion packages to reduce cold start time
4341 config . optimizeDeps = {
4442 ...config . optimizeDeps ,
4543 include : [
@@ -50,13 +48,7 @@ const config: StorybookConfig = {
5048 ] ,
5149 } ;
5250
53- // Ensure emotion packages are resolved correctly
54- config . resolve = {
55- ...config . resolve ,
56- dedupe : [ '@emotion/react' , '@emotion/styled' , '@emotion/cache' ] ,
57- } ;
58-
5951 return config ;
6052 } ,
6153} ;
62- export default config ;
54+ export default config ;
0 commit comments