import { rolldown } from 'rolldown'; import fs from 'fs-extra'; import path from 'path'; const production = process.env.NODE_ENV === 'production'; async function build() { try { await fs.remove('dist'); await fs.ensureDir('dist'); const jsBundle = await rolldown({ input: 'src/js/script.ts', output: { file: 'dist/bundle.js', format: 'es', sourcemap: !production, }, }); await jsBundle.write(); await fs.copy('src/css/style.css', 'dist/bundle.css'); await fs.copy('src/assets', 'dist', { overwrite: true, }); let html = await fs.readFile('src/index.html', 'utf8'); await fs.writeFile('dist/index.html', html); } catch (err) { console.error('Build failed:', err); process.exit(1); } } build();