aboutsummaryrefslogtreecommitdiffstats
path: root/.storybook/main.ts
blob: 76b1316b0ad0b3671a4e7bfd1222b7339c89c9af (plain)
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
import type { StorybookConfig } from '@storybook/nextjs';
import { RuleSetRule } from 'webpack';

const config: StorybookConfig = {
  stories: [
    '../src/**!(content)/*.mdx',
    '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)',
  ],
  addons: [
    '@storybook/addon-links',
    '@storybook/addon-essentials',
    '@storybook/addon-interactions',
    'storybook-dark-mode',
  ],
  framework: {
    name: '@storybook/nextjs',
    options: {},
  },
  docs: {
    autodocs: 'tag',
  },
  staticDirs: ['../public'],
  webpackFinal: async (config) => {
    // Use SVGR for SVG files. See: https://medium.com/@derek_19900/config-storybook-4-to-use-svgr-webpack-plugin-22cb1152f004
    const rules = config.module?.rules as RuleSetRule[];
    const fileLoaderRule = rules.find(
      (rule) => rule?.test instanceof RegExp && rule.test.test('.svg')
    );

    if (fileLoaderRule) fileLoaderRule.exclude = /\.svg$/;

    rules.push({
      test: /\.svg$/,
      use: [{ loader: '@svgr/webpack', options: { dimensions: false } }],
    });

    /** @type {import('next').NextConfig} */
    const nextConfig = require('../next.config');

    return {
      ...config,
      ...nextConfig.webpack,
    };
  },
};
export default config;