Skip to content

Commit 655fff8

Browse files
committed
upd
1 parent c75a761 commit 655fff8

File tree

1 file changed

+13
-82
lines changed

1 file changed

+13
-82
lines changed

.storybook/main.js

Lines changed: 13 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ export default defineMain({
1616
builder: '@storybook/builder-vite',
1717
},
1818
framework: '@storybook/nextjs-vite',
19-
features: {},
20-
typescript: {},
21-
docs: {},
19+
typescript: {
20+
check: false,
21+
},
2222

2323
async viteFinal(config) {
2424
// Ensure NODE_ENV is aligned with Storybook mode
@@ -27,12 +27,12 @@ export default defineMain({
2727
? 'production'
2828
: 'development'
2929

30-
// Make sure React (and other libs) see the correct NODE_ENV
31-
// IMPORTANT: Preserve all Storybook internal definitions
30+
// CRITICAL: Preserve all Storybook internal definitions
31+
// Don't create a new object - modify existing one to preserve Storybook's defines
3232
if (!config.define) {
3333
config.define = {}
3434
}
35-
// Only set NODE_ENV, don't override Storybook's internal definitions
35+
// Only add/update NODE_ENV, preserve all other Storybook definitions
3636
config.define['process.env.NODE_ENV'] = JSON.stringify(nodeEnv)
3737

3838
// Ensure React is properly resolved and deduplicated
@@ -55,85 +55,16 @@ export default defineMain({
5555
config.build.modulePreload !== false
5656
? {
5757
resolveDependencies: (_filename, deps) =>
58-
deps.filter(dep => !dep.includes('vite-inject-mocker-entry.js')),
58+
deps.filter(
59+
dep =>
60+
!dep.includes('vite-inject-mocker-entry.js') &&
61+
!dep.includes('vite-inject-mocker')
62+
),
5963
}
6064
: false
6165

62-
// Optimize chunk splitting for better performance
63-
// CRITICAL: Don't split Storybook modules - let Storybook handle its own chunks
64-
config.build.rollupOptions = config.build.rollupOptions ?? {}
65-
config.build.rollupOptions.output =
66-
config.build.rollupOptions.output ?? {}
67-
68-
const originalManualChunks =
69-
config.build.rollupOptions.output.manualChunks
70-
71-
config.build.rollupOptions.output.manualChunks = id => {
72-
// Respect existing manualChunks function if present
73-
if (typeof originalManualChunks === 'function') {
74-
const result = originalManualChunks(id)
75-
if (result) return result
76-
}
77-
78-
// CRITICAL: Never split Storybook internal modules
79-
// Storybook needs its modules to load correctly in production
80-
if (
81-
id.includes('@storybook') ||
82-
id.includes('storybook/') ||
83-
id.includes('.storybook/')
84-
) {
85-
return undefined
86-
}
87-
88-
// Only split node_modules; app code stays as is
89-
if (!id.includes('node_modules')) {
90-
return undefined
91-
}
92-
93-
// MUI packages
94-
if (
95-
id.includes('@mui/material') ||
96-
id.includes('@mui/system') ||
97-
id.includes('@mui/styled-engine')
98-
) {
99-
return 'mui'
100-
}
101-
if (id.includes('@mui/icons-material')) {
102-
return 'mui-icons'
103-
}
104-
if (id.includes('@mui/x-date-pickers')) {
105-
return 'mui-date-pickers'
106-
}
107-
108-
// TanStack packages
109-
if (id.includes('@tanstack/react-table')) {
110-
return 'tanstack-table'
111-
}
112-
if (id.includes('@tanstack/react-virtual')) {
113-
return 'tanstack-virtual'
114-
}
115-
116-
// GSAP
117-
if (id.includes('gsap')) {
118-
return 'gsap'
119-
}
120-
121-
// Fonts
122-
if (id.includes('@fontsource')) {
123-
return 'fonts'
124-
}
125-
126-
// React DOM
127-
if (id.includes('react-dom')) {
128-
return 'react-dom'
129-
}
130-
131-
// Default vendor chunk
132-
return 'vendor'
133-
}
134-
135-
// Increase chunk size warning limit (KB)
136-
config.build.chunkSizeWarningLimit = 1000
66+
// Let Storybook handle its own chunk splitting - don't interfere
67+
// This ensures all Storybook modules load correctly in production
13768

13869
return config
13970
},

0 commit comments

Comments
 (0)