|
| 1 | +module.exports = { |
| 2 | + stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], |
| 3 | + staticDirs: ['../public'], |
| 4 | + addons: [ |
| 5 | + '@storybook/addon-links', |
| 6 | + '@storybook/addon-essentials', |
| 7 | + '@storybook/addon-interactions', |
| 8 | + '@storybook/preset-scss', |
| 9 | + { |
| 10 | + /** |
| 11 | + * Fix Storybook issue with PostCSS@8 |
| 12 | + * @see https://github.com/storybookjs/storybook/issues/12668#issuecomment-773958085 |
| 13 | + */ |
| 14 | + name: '@storybook/addon-postcss', |
| 15 | + options: { |
| 16 | + cssLoaderOptions: { |
| 17 | + // When you have splitted your css over multiple files |
| 18 | + // and use @import('./other-styles.css') |
| 19 | + importLoaders: 1, |
| 20 | + }, |
| 21 | + postcssLoaderOptions: { |
| 22 | + implementation: require('postcss'), |
| 23 | + }, |
| 24 | + }, |
| 25 | + }, |
| 26 | + ], |
| 27 | + framework: '@storybook/react', |
| 28 | + core: { |
| 29 | + builder: '@storybook/builder-webpack5', |
| 30 | + }, |
| 31 | + webpackFinal: async (config) => { |
| 32 | + /** |
| 33 | + * Add support for alias-imports |
| 34 | + * @see https://github.com/storybookjs/storybook/issues/11989#issuecomment-715524391 |
| 35 | + */ |
| 36 | + config.resolve.alias = { |
| 37 | + ...config.resolve?.alias, |
| 38 | + '@': [ |
| 39 | + require('path').resolve(__dirname, '../src/'), |
| 40 | + require('path').resolve(__dirname, '../'), |
| 41 | + ], |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Fixes font import with / |
| 46 | + * @see https://github.com/storybookjs/storybook/issues/12844#issuecomment-867544160 |
| 47 | + */ |
| 48 | + config.resolve.roots = [ |
| 49 | + require('path').resolve(__dirname, '../public'), |
| 50 | + 'node_modules', |
| 51 | + ] |
| 52 | + |
| 53 | + config.module.rules.push({ |
| 54 | + test: /\.s[ac]ss$/, |
| 55 | + use: [ |
| 56 | + { |
| 57 | + loader: 'postcss-loader', |
| 58 | + options: { |
| 59 | + postcssOptions: { |
| 60 | + plugins: [require('tailwindcss'), require('autoprefixer')], |
| 61 | + }, |
| 62 | + }, |
| 63 | + }, |
| 64 | + { |
| 65 | + loader: 'sass-loader', |
| 66 | + options: { |
| 67 | + implementation: require('sass'), |
| 68 | + }, |
| 69 | + }, |
| 70 | + ], |
| 71 | + include: require('path').resolve(__dirname, '../'), |
| 72 | + }) |
| 73 | + |
| 74 | + return config |
| 75 | + }, |
| 76 | +} |
0 commit comments