import { mergeConfig } from 'vite';
import path from 'path';

/** @type { import('@storybook/react-vite').StorybookConfig } */
const config = {
  stories: [
    '../src/**/*.mdx',
    '../src/components/**/*.stories.@(js|jsx|ts|tsx)'
  ],
  addons: [
    '@chromatic-com/storybook',
    '@storybook/addon-docs',
    '@storybook/addon-a11y',
    '@storybook/addon-vitest'
  ],
  framework: {
    name: '@storybook/react-vite',
    options: {}
  },

  // 👇 Add alias support here
  viteFinal: async (config, { configType }) => {
    return mergeConfig(config, {
      resolve: {
        alias: {
          '@components': path.resolve(__dirname, '../src/components'),
          '@Base': path.resolve(__dirname, '../src/components/Base'),
          '@Shared': path.resolve(__dirname, '../src/components/Shared'),
          '@lib': path.resolve(__dirname, '../src/lib'),
          '@assets': path.resolve(__dirname, '../src/assets')
        }
      }
    });
  }
};

export default config;
