import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import svgLoader from 'vite-svg-loader'
import { fileURLToPath, URL } from 'node:url'

export default defineConfig({
  plugins: [vue(), svgLoader()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  publicDir: 'public',
  server: {
    host: '0.0.0.0',
    port: 4173,
    open: true,
    // ffmpeg.wasm 需要 SharedArrayBuffer，必须配置 COOP/COEP 实现跨域隔离
    // 用 credentialless 而非 require-corp，避免 Vite HMR iframe / 扩展 iframe 被阻塞
    headers: {
      'Cross-Origin-Opener-Policy': 'same-origin',
      'Cross-Origin-Embedder-Policy': 'credentialless',
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        api: 'modern-compiler',
      }
    }
  }
})
