Skip to content

Commit c0daf21

Browse files
Fix Storybook 10 build: complete v7→v10 migration (#3007)
* Initial plan * Initial plan for fixing storybook build failures Co-authored-by: llastflowers <55068883+llastflowers@users.noreply.github.com> * Fix Storybook 10 build: update packages, add SCSS/Babel/docs support, fix compat shims Co-authored-by: llastflowers <55068883+llastflowers@users.noreply.github.com> * Address code review: remove unused assert dep, rename config var, clean up shim script Co-authored-by: llastflowers <55068883+llastflowers@users.noreply.github.com> * Fix docs npm install failure due to storybook peer dependency conflicts (#3008) * Initial plan * fix: resolve storybook peer dependency conflicts in docs install - Update @geometricpanda/storybook-addon-badges to ^2.0.5 which supports @storybook/blocks@^8.3.0 (v2.0.0 only supported ^7.0.0) - Add docs/.npmrc with legacy-peer-deps=true to handle the intentional mixed storybook 8/10 package setup used by shims and webpack aliases Co-authored-by: llastflowers <55068883+llastflowers@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: llastflowers <55068883+llastflowers@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: llastflowers <55068883+llastflowers@users.noreply.github.com>
1 parent 7d22baa commit c0daf21

7 files changed

Lines changed: 2469 additions & 5039 deletions

File tree

docs/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

docs/.storybook/main.js

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
import sass from 'sass'
2+
import {createRequire} from 'module'
3+
import {fileURLToPath} from 'url'
4+
5+
const require = createRequire(import.meta.url)
26

37
/** @type { import('@storybook/react-webpack5').StorybookConfig } */
48
const config = {
59
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|ts|tsx)'],
610
addons: [
7-
'@storybook/addon-links',
8-
'@storybook/addon-essentials',
9-
'@storybook/addon-interactions',
11+
'@storybook/addon-webpack5-compiler-babel',
12+
'@storybook/addon-docs',
1013
'storybook-addon-pseudo-states',
11-
'@storybook/addon-storysource',
1214
'@geometricpanda/storybook-addon-badges',
13-
{
14-
name: '@storybook/addon-styling',
15-
options: {
16-
sass: {
17-
implementation: sass,
18-
},
19-
},
20-
},
2115
],
2216
framework: {
2317
name: '@storybook/react-webpack5',
@@ -27,5 +21,30 @@ const config = {
2721
autodocs: 'tag',
2822
},
2923
staticDirs: ['../stories/static'],
24+
async webpackFinal(webpackConfig) {
25+
// Alias @storybook/blocks to the v10-compatible addon-docs/blocks
26+
webpackConfig.resolve = webpackConfig.resolve || {}
27+
webpackConfig.resolve.alias = {
28+
...webpackConfig.resolve.alias,
29+
'@storybook/blocks': fileURLToPath(import.meta.resolve('@storybook/addon-docs/blocks')),
30+
}
31+
32+
// Add SCSS support using sass-loader
33+
webpackConfig.module.rules.push({
34+
test: /\.s[ac]ss$/,
35+
use: [
36+
require.resolve('style-loader'),
37+
require.resolve('css-loader'),
38+
{
39+
loader: require.resolve('sass-loader'),
40+
options: {
41+
implementation: sass,
42+
},
43+
},
44+
],
45+
sideEffects: true,
46+
})
47+
return webpackConfig
48+
},
3049
}
3150
export default config

docs/.storybook/manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {addons} from '@storybook/manager-api'
1+
import {addons} from 'storybook/manager-api'
22
import theme from './theme'
33

44
addons.setConfig({

docs/.storybook/theme.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)