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

export default defineConfig({
  resolve: {
    alias: {
      '@web/state': resolve(__dirname, '../state/src/index.js'),
      '@web/base': resolve(__dirname, '../base/src/index.js'),
      '@web/mindmap': resolve(__dirname, 'src/index.js')
    }
  },
  server: {
    fs: {
      allow: ['..']
    }
  },
  build: {
    lib: {
      entry: resolve(__dirname, 'src/index.js'),
      name: 'Mindmap',
      formats: ['es']
    },
    rollupOptions: {
      external: ['@web/state', '@web/base'],
      output: [
        {
          format: 'es',
          entryFileNames: 'mindmap.js',
          minifyInternalExports: false
        },
        {
          format: 'es',
          entryFileNames: 'mindmap.min.js',
          plugins: [terser()]
        }
      ]
    },
    minify: false
  }
});
