import { defineConfig } from 'vite'

export default defineConfig({
  resolve: {
    alias: {
      '@': '/src'
    }
  },
  build: {
    lib: {
      entry: 'src/main.ts',
      name: 'kernel',
      formats: ['es', 'iife'],
      fileName: (format) => format === 'es' ? 'assets/index.js' : 'assets/index.global.js',
    },
    target: 'esnext',
    outDir: 'dist',
    assetsDir: 'assets',
    copyPublicDir: true,
    minify: false,
    reportCompressedSize: false,
    rollupOptions: {
      output: {
        inlineDynamicImports: true,
      },
    },
  },
  optimizeDeps: {
    exclude: ['@ffmpeg/ffmpeg', '@ffmpeg/util']
  },
  server: {
    headers: {
      'Cross-Origin-Opener-Policy': 'same-origin',
      'Cross-Origin-Embedder-Policy': 'require-corp'
    }
  }
})
