import { defineConfig } from 'vite';
import preact from '@preact/preset-vite';

// Build artefact lives at apps/widget-telegram/dist/. The deploy step
// (out of repo) rsyncs this into ~/vojo/widgets/telegram/ on the server,
// which Caddy serves from /var/www/widgets/telegram via the
// widgets.vojo.chat block (see docs/plans/bots_tab.md Phase 3).
//
// `base: './'` keeps every generated asset path relative so the same
// build can sit under /telegram/ on widgets.vojo.chat without rewrites.
export default defineConfig({
  base: './',
  plugins: [preact()],
  build: {
    target: 'es2020',
    sourcemap: true,
    // Inline CSS for a single round-trip; the widget is small and the
    // host's iframe handshake budget is already tight (10s default).
    cssCodeSplit: false,
  },
  server: {
    port: 8081,
    host: true,
  },
});
