import { defineConfig } from 'vite';

export default defineConfig({
  server: {
    port: 3000,
    open: true,
  },
  build: {
    outDir: 'dist',
  },
  optimizeDeps: {
    // esptool-js uses dynamic import() for chip targets (e.g. esp32s3.js); include them
    // so Vite pre-bundles them and the runtime fetch resolves.
    include: [
      'esptool-js',
      'esptool-js/lib/targets/esp32.js',
      'esptool-js/lib/targets/esp32c2.js',
      'esptool-js/lib/targets/esp32c3.js',
      'esptool-js/lib/targets/esp32c5.js',
      'esptool-js/lib/targets/esp32c6.js',
      'esptool-js/lib/targets/esp32c61.js',
      'esptool-js/lib/targets/esp32h2.js',
      'esptool-js/lib/targets/esp32p4.js',
      'esptool-js/lib/targets/esp32s2.js',
      'esptool-js/lib/targets/esp32s3.js',
      'esptool-js/lib/targets/esp8266.js',
    ],
  },
});
