|
1 | 1 | import type { StorybookConfig } from '@storybook/react-webpack5'; |
| 2 | +import { join } from 'path'; |
| 3 | +import { fileURLToPath } from 'url'; |
2 | 4 |
|
3 | | -import { dirname, join } from 'path'; |
4 | | - |
5 | | -/** |
6 | | - * This function is used to resolve the absolute path of a package. |
7 | | - * It is needed in projects that use Yarn PnP or are set up within a monorepo. |
8 | | - */ |
9 | | -function getAbsolutePath(value: string): any { |
10 | | - return dirname(require.resolve(join(value, 'package.json'))); |
11 | | -} |
| 5 | +const __filename = fileURLToPath(import.meta.url); |
| 6 | +const __dirname = join(__filename, '..'); |
12 | 7 |
|
13 | 8 | const config: StorybookConfig = { |
14 | 9 | stories: ['../packages/**/src/**/?(*.)(story|stories).(js|jsx|ts|tsx|mdx)'], |
15 | 10 |
|
16 | 11 | addons: [ |
17 | | - getAbsolutePath('@storybook/addon-essentials'), |
18 | | - getAbsolutePath('@storybook/addon-interactions'), |
19 | | - getAbsolutePath('@storybook/addon-storysource'), |
20 | | - getAbsolutePath('@storybook/addon-a11y'), |
21 | | - getAbsolutePath('storybook-addon-deep-controls'), |
22 | | - getAbsolutePath('storybook-dark-mode'), |
23 | | - getAbsolutePath('@storybook/addon-webpack5-compiler-babel'), |
| 12 | + '@storybook/addon-essentials', |
| 13 | + '@storybook/addon-interactions', |
| 14 | + '@storybook/addon-storysource', |
| 15 | + '@storybook/addon-a11y', |
| 16 | + 'storybook-addon-deep-controls', |
| 17 | + 'storybook-dark-mode', |
| 18 | + '@storybook/addon-webpack5-compiler-babel', |
24 | 19 | ], |
25 | 20 |
|
26 | 21 | framework: { |
27 | | - name: getAbsolutePath('@storybook/react-webpack5'), |
28 | | - options: {}, |
| 22 | + name: '@storybook/react-webpack5', |
| 23 | + options: { |
| 24 | + builder: { |
| 25 | + useSWC: false, |
| 26 | + }, |
| 27 | + }, |
| 28 | + }, |
| 29 | + |
| 30 | + webpackFinal: async (config) => { |
| 31 | + if (!config.resolve) { |
| 32 | + config.resolve = {}; |
| 33 | + } |
| 34 | + if (!config.resolve.alias) { |
| 35 | + config.resolve.alias = {}; |
| 36 | + } |
| 37 | + config.resolve.alias = { |
| 38 | + ...config.resolve.alias, |
| 39 | + 'decap-cms-ui-next': join(__dirname, '../packages/decap-cms-ui-next/src'), |
| 40 | + 'decap-cms-locales': join(__dirname, '../packages/decap-cms-locales/src'), |
| 41 | + }; |
| 42 | + return config; |
29 | 43 | }, |
30 | 44 | }; |
31 | 45 | export default config; |
0 commit comments