|
1 | | -const path = require('path'); |
2 | | - |
3 | | -module.exports = { |
| 1 | +/** @type { import('@storybook/react-webpack5').StorybookConfig } */ |
| 2 | +const config = { |
4 | 3 | stories: ['../client/**/*.stories.(jsx|mdx)'], |
5 | 4 | addons: [ |
6 | | - '@storybook/addon-actions', |
7 | | - '@storybook/addon-docs', |
8 | | - '@storybook/addon-knobs', |
9 | 5 | '@storybook/addon-links', |
10 | | - 'storybook-addon-theme-playground/dist/register' |
| 6 | + '@storybook/addon-essentials', |
| 7 | + '@storybook/addon-interactions' |
11 | 8 | ], |
12 | | - webpackFinal: async config => { |
13 | | - // do mutation to the config |
14 | | - |
15 | | - const rules = config.module.rules; |
16 | | - |
17 | | - // modify storybook's file-loader rule to avoid conflicts with svgr |
18 | | - const fileLoaderRule = rules.find(rule => rule.test.test('.svg')); |
19 | | - fileLoaderRule.exclude = path.resolve(__dirname, '../client'); |
| 9 | + framework: { |
| 10 | + name: '@storybook/react-webpack5', |
| 11 | + options: {} |
| 12 | + }, |
| 13 | + docs: { |
| 14 | + autodocs: 'tag' |
| 15 | + }, |
| 16 | + async webpackFinal(config) { |
| 17 | + // https://storybook.js.org/docs/react/builders/webpack |
| 18 | + // this modifies the existing image rule to exclude .svg files |
| 19 | + // since we want to handle those files with @svgr/webpack |
| 20 | + const imageRule = config.module.rules.find(rule => rule.test.test('.svg')) |
| 21 | + imageRule.exclude = /\.svg$/ |
20 | 22 |
|
21 | | - // use svgr for svg files |
22 | | - rules.push({ |
| 23 | + // configure .svg files to be loaded with @svgr/webpack |
| 24 | + config.module.rules.push({ |
23 | 25 | test: /\.svg$/, |
24 | | - use: ["@svgr/webpack"], |
| 26 | + use: ['@svgr/webpack'] |
25 | 27 | }) |
26 | 28 |
|
27 | | - return config; |
| 29 | + return config |
28 | 30 | }, |
29 | 31 | }; |
| 32 | + |
| 33 | +export default config; |
| 34 | + |
| 35 | + |
0 commit comments