-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.config.ts
39 lines (34 loc) · 1.04 KB
/
build.config.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
import * as esbuild from 'https://deno.land/x/esbuild@v0.19.12/mod.js';
import { green } from 'https://deno.land/std@0.211.0/fmt/colors.ts';
import { parseArgs } from 'https://deno.land/std@0.211.0/cli/parse_args.ts';
const args = parseArgs<{
watch: boolean | undefined,
develope: boolean | undefined,
logLevel: esbuild.LogLevel
}>(Deno.args);
console.log('Build process started.');
const tsConfig : esbuild.BuildOptions = {
allowOverwrite: true,
logLevel: args.logLevel ?? 'info',
legalComments: args.develope ? 'inline' : 'none',
color: true,
minify: !args.develope ?? true,
outfile: './dist/bundle.min.js',
entryPoints: [
'./src/index.ts'
],
bundle: true,
platform: 'node',
target: 'node20',
sourcemap: false,
keepNames: true
}
const timestampNow = Date.now();
if (args.watch) {
esbuild.context(tsConfig).then((context) => context.watch());
} else {
esbuild.build(tsConfig).then(() => {
console.log(green(`Build process finished in ${(Date.now() - timestampNow).toString()}ms.`));
esbuild.stop();
})
}