-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathesbuild.ts
50 lines (43 loc) · 1.3 KB
/
esbuild.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
#!/usr/bin/env ts-node
/*!
* Script to build TS and JS with esbuild.
* Copyright 2020-2024 Chocolatey Software
* Licensed under Apache License (https://github.com/chocolatey/choco-theme/blob/main/LICENSE)
*/
import * as process from 'process';
import * as esbuild from 'esbuild';
const init = async () => {
const minify = process.argv.includes('--minify');
const banner: string = `/*!
* choco-theme v0.8.4 (https://github.com/chocolatey/choco-theme#readme)
* Copyright 2020-2024 Chocolatey Software
* Licensed under MIT (https://github.com/chocolatey/choco-theme/blob/main/LICENSE)
*/`;
const esbuildOptions: esbuild.BuildOptions = {
entryPoints: ['js/*.js'],
target: 'es2015',
bundle: true,
banner: {
js: banner
},
outdir: 'dist/js'
};
if (minify) {
console.log('🚀 Minifying JS...');
await esbuild.build({
...esbuildOptions,
minify: true,
outExtension: { '.js': '.min.js' }
}).then(() => {
console.log('✅ JS minified');
});
} else {
console.log('🚀 Compiling JS and TS...');
await esbuild.build({
...esbuildOptions
}).then(() => {
console.log('✅ JS and TS compiled');
});
}
};
init();