import { defineConfig } from 'vite';
import terser from '@rollup/plugin-terser';
import { resolve } from 'path';

export default defineConfig({
  resolve: {
    alias: {
      '@web/kanban': resolve(__dirname, 'src/index.js'),
    },
  },
  build: {
    lib: {
      entry: 'src/index.js',
      name: 'Kanban',
      fileName: (format) => `kanban${format === 'es' ? '' : '.min'}.js`,
      formats: ['es'],
    },
    rollupOptions: {
      output: [
        {
          format: 'es',
          entryFileNames: 'kanban.js',
          plugins: [], // 不压缩
        },
        {
          format: 'es',
          entryFileNames: 'kanban.min.js',
          plugins: [terser()], // 压缩
        },
      ],
    },
    minify: false, // 由 rollupOptions 控制
  },
});
