import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { viteSingleFile } from 'vite-plugin-singlefile'
import { resolve } from 'path'

export default defineConfig(({ mode }) => ({
  plugins: [vue(), viteSingleFile()],
  resolve: {
    alias: {
      '@shared': resolve(__dirname, 'src/shared'),
    },
  },
  build: {
    outDir: resolve(__dirname, '../web'),
    emptyOutDir: false,
    cssCodeSplit: false,
    assetsInlineLimit: 10_000_000,
    rollupOptions: {
      input: mode === 'overlay'
        ? resolve(__dirname, 'overlay.html')
        : resolve(__dirname, 'settings.html'),
      output: {
        inlineDynamicImports: true,
      },
    },
    target: 'esnext',
  },
  css: {
    postcss: './postcss.config.js',
  },
}))
