import esbuild from 'esbuild';
import { NovadiUnplugin } from '@novadi/core/unplugin';
import { copyFileSync, mkdirSync } from 'fs';

// Ensure dist/css directory exists
mkdirSync('dist/css', { recursive: true });

// Copy calendar CSS
copyFileSync(
  'node_modules/calendar/dist/css/calendar.css',
  'dist/css/calendar.css'
);

await esbuild.build({
  entryPoints: ['src/index.ts'],
  bundle: true,
  outfile: 'dist/bundle.js',
  format: 'esm',
  platform: 'browser',
  plugins: [NovadiUnplugin.esbuild()]
});

console.log('Build complete');
