Skip to content

Commit 6864b27

Browse files
authored
refactor(Storybook): Migrate to Storybook v10 with Vite for faster builds (#2074)
1 parent 3226b1c commit 6864b27

File tree

383 files changed

+10350
-13202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

383 files changed

+10350
-13202
lines changed

.storybook/main.js

Lines changed: 0 additions & 65 deletions
This file was deleted.

.storybook/main.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**
2+
* Copyright Zendesk, Inc.
3+
*
4+
* Use of this source code is governed under the Apache License, Version 2.0
5+
* found at http://www.apache.org/licenses/LICENSE-2.0.
6+
*/
7+
8+
import { readdirSync } from 'node:fs';
9+
import path from 'node:path';
10+
import { fileURLToPath } from 'node:url';
11+
import type { StorybookConfig } from '@storybook/react-vite';
12+
import svgr from 'vite-plugin-svgr';
13+
14+
const __filename = fileURLToPath(import.meta.url);
15+
const __dirname = path.dirname(__filename);
16+
17+
const PACKAGE_NAMES = readdirSync(path.resolve(__dirname, '../packages')).filter(
18+
name => name !== '.template'
19+
);
20+
21+
const config: StorybookConfig = {
22+
stories: ['../packages/*/demo/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'],
23+
staticDirs: ['./static'],
24+
25+
addons: ['@storybook/addon-a11y', '@storybook/addon-designs', '@storybook/addon-docs'],
26+
27+
framework: {
28+
name: '@storybook/react-vite',
29+
options: {
30+
strictMode: true
31+
}
32+
},
33+
34+
core: {
35+
disableWhatsNewNotifications: true,
36+
disableTelemetry: true
37+
},
38+
39+
viteFinal: async viteConfig => {
40+
const { mergeConfig } = await import('vite');
41+
42+
return mergeConfig(viteConfig, {
43+
assetsInclude: ['**/*.md'],
44+
define: {
45+
PACKAGE_VERSION: JSON.stringify('storybook')
46+
},
47+
plugins: [
48+
svgr({
49+
include: '**/*.svg',
50+
svgrOptions: {
51+
plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx'],
52+
svgoConfig: {
53+
plugins: [
54+
{
55+
name: 'addAttributesToSVGElement',
56+
params: {
57+
attributes: [{ focusable: 'false' }, { 'aria-hidden': 'true' }]
58+
}
59+
}
60+
]
61+
}
62+
}
63+
})
64+
],
65+
resolve: {
66+
alias: PACKAGE_NAMES.reduce<Record<string, string>>((aliases, packageName) => {
67+
aliases[`@zendeskgarden/react-${packageName}`] = path.resolve(
68+
__dirname,
69+
`../packages/${packageName}/src`
70+
);
71+
72+
return aliases;
73+
}, {})
74+
}
75+
});
76+
},
77+
78+
typescript: {
79+
reactDocgen: 'react-docgen-typescript'
80+
}
81+
};
82+
83+
export default config;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
* found at http://www.apache.org/licenses/LICENSE-2.0.
66
*/
77

8-
import { create } from '@storybook/theming/create';
9-
import { addons } from '@storybook/addons';
8+
import { create } from 'storybook/theming/create';
9+
import { addons } from 'storybook/manager-api';
1010
import { DEFAULT_THEME } from '../packages/theming/src';
1111

1212
addons.setConfig({
1313
panelPosition: 'right',
14+
// @ts-expect-error - Storybook types don't match implementation; omitting `base` allows OS theme inheritance
1415
theme: create({
1516
brandTitle: 'Zendesk Garden React Components',
1617
brandUrl: 'https://github.com/zendeskgarden/react-components',
17-
brandImage: null,
1818
colorSecondary: DEFAULT_THEME.palette.blue[600],
1919
fontBase: DEFAULT_THEME.fonts.system,
2020
fontCode: DEFAULT_THEME.fonts.mono

.storybook/preview.js

Lines changed: 0 additions & 143 deletions
This file was deleted.

0 commit comments

Comments
 (0)