import { defineConfig } from 'vite';
import dts from "vite-plugin-dts";
import path from "path";

const common = [
  'mobx-react-lite',
  'react',
  'react-dom',
  'antd',
  '@ant-design/pro-components'
]
export default defineConfig({
  build: {
    rollupOptions: {
      external: (id, _s, _d) => {
        if (common.includes(id)) {
          return true;
        }
        return /^@lowcode-set-up-platform/.test(id)
      }
    },
    outDir: 'lib',
    lib: {
      name: 'ConfigurationSetter',
      entry: './src/index.tsx',
      fileName: (f, n) => {
        if (f == 'es') {
          return `${n}.${f}m.js`
        }
        if (f === 'cjs') {
          return `${n}.js`
        }
        return `${n}.${f}.js`

      },
      formats: ['es', 'cjs']
    }
  },
  plugins: [dts({
    root: path.resolve(__dirname),
  })]
});
