import { defineConfig } from 'vite';
import tailwindcss from '@tailwindcss/vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';

export default defineConfig({
  base: './', // This makes all assets use relative paths
  plugins: [
    tailwindcss(),
    viteStaticCopy({
      targets: [
        {
          src: 'images/*',
          dest: 'images',
        },
      ],
    }),
  ],
  server: {
    watch: {
      usePolling: true,
    },
  },
  build: {
    minify: false,
    terserOptions: {
      compress: false,
      mangle: false,
    },
    rollupOptions: {
      input: {
        main: 'index.html',
      },
      output: {
        format: 'iife',
        entryFileNames: '[name].js',
        chunkFileNames: '[name]-[hash].js',
        assetFileNames: 'assets/[name]-[hash].[ext]',
        sanitizeFileName: name => name.replace(/\.[jt]sx?$/, ''),
      },
    },
    assetsInlineLimit: 0,
    target: 'esnext',
    modulePreload: false,
    cssCodeSplit: false,
  },
});
