import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';

export default defineConfig(({ mode }) => {
  return {
    plugins: [vue()],
    base: '/',
    build: {
      outDir: 'dist',
      rollupOptions: {
        output: {
          entryFileNames: 'assets/dist/[name].js',
          assetFileNames: 'assets/dist/[name].[ext]',
        },
      },
      sourcemap: mode === 'staging',
      minify: mode === 'production' ? 'esbuild' : false,
    },
    server: {
      cors: true,
      watch: {
        ignored: [
          '**/node_modules/**',
          '**/.git/**',
          '**/.cache/**',
          '**/.vite/**',
          '**/dist/**',
          '**/*.log',
          '**/.idea/**',
          '**/.vscode/**',
          '**/public/assets/**',
          '**/local/**',
          '/public/**',
        ],
      },
    },
  };
});
