blob: 6cc77657c9b3433356b9e27d1486e095261fc434 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
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();
|