import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import { resolve } from 'path'

export default defineConfig({
  plugins: [svelte()],
  base: '/static/dist/',
  build: {
    outDir: resolve(__dirname, '../static/dist'),
    emptyOutDir: true,
    rollupOptions: {
      input: resolve(__dirname, 'src/main.ts'),
      output: {
        entryFileNames: 'main.js',
        chunkFileNames: '[name].js',
        assetFileNames: '[name][extname]',
        // Alles in eine Datei — kein dynamisches Chunking für einfaches Deploy
        manualChunks: undefined,
      },
    },
  },
  resolve: {
    alias: {
      '@core': resolve(__dirname, '../static/js/core'),
      '@panels': resolve(__dirname, '../static/js/panels'),
    },
  },
})
