-
-
Notifications
You must be signed in to change notification settings - Fork 269
/
Copy pathmain.ts
60 lines (55 loc) · 1.62 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const svgoConfig = require('../common/config/svgo');
import type { StorybookConfig } from '@storybook/nextjs';
const config: StorybookConfig = {
stories: [
'../components/**/__stories__/*.mdx',
'../components/**/__stories__/*.stories.@(js|jsx|mjs|ts|tsx)',
],
staticDirs: ['../public'],
addons: [
'@storybook/addon-essentials',
{
name: '@storybook/addon-styling',
/** @see https://storybook.js.org/recipes/tailwindcss#:~:text=then%20leave%20the%20options%20object%20empty. */
options: {},
},
],
webpackFinal: async config => {
// Find the Storybook Webpack rule relevant to SVG files.
// @ts-expect-error => 'config.module' is possibly 'undefined'.ts(18048)
const imageRule = config.module.rules.find(rule => {
// @ts-expect-error => 'rule' is possibly 'null' or 'undefined'.ts(18049)
if (rule.test && rule.test.test('.svg')) {
console.log({ rule });
return true;
} else {
return false;
}
});
// Ignore what Storybook does
// @ts-expect-error => 'imageRule' is possibly 'null' or 'undefined'.ts(18049)
imageRule.exclude = /\.svg$/;
// Configure .svg files to be loaded with @svgr/webpack
// @ts-expect-error => 'config.module' is possibly 'undefined'.ts(18048)
config.module.rules.push({
test: /\.svg$/,
use: [
{
loader: '@svgr/webpack',
options: {
svgo: svgoConfig,
},
},
],
});
return config;
},
framework: {
name: '@storybook/nextjs',
options: {},
},
docs: {
autodocs: true,
},
};
export default config;