-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbun-build.ts
56 lines (49 loc) · 1.55 KB
/
bun-build.ts
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import Bun from 'bun';
import chalk from 'chalk';
import packageJson from './package.json';
const banner = [
`/*!`,
` * ${packageJson.name}@${packageJson.version} ${packageJson.repository.url}`,
` * Compiled ${new Date().toUTCString().replace(/GMT/g, 'UTC')}`,
` * Copyright (c) ${new Date().getFullYear()} Jared Bates, Evitca Studio, "doubleactii"`,
` *`,
` * ${packageJson.name} is licensed under the MIT License.`,
` * http://www.opensource.org/licenses/mit-license`,
` */`,
].join('\n');
function logMessage(pLevel: string, pMessage: string): void {
const colors = { error: '#c42847', info: '#ffa552' };
const levelFormatted = pLevel.charAt(0).toUpperCase() + pLevel.slice(1);
const color = colors[pLevel] || '#ffa552';
console.log(chalk.hex(color)(`[${levelFormatted}]`), `${pMessage}`);
};
const oldNow = Date.now();
await Promise.all([
// Natural version
Bun.build({
entrypoints: ['./src/index.ts'],
outdir: './dist/bundle',
naming: 'kit.js',
banner: banner,
target: 'browser'
}),
// Minified version
Bun.build({
entrypoints: ['./src/index.ts'],
outdir: './dist/bundle/min',
naming: 'kit.min.js',
minify: true,
banner: banner,
target: 'browser'
}),
// CLI version
Bun.build({
entrypoints: ['./bin/cli.ts'],
outdir: './lib/bundle/cli',
naming: 'cli.js',
banner: banner,
target: 'node'
})
]);
const elapsed = Date.now() - oldNow;
logMessage('info', `Client Build took: ${elapsed}ms`);