forked from eclipse-cdt-cloud/cdt-gdb-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.js
48 lines (43 loc) · 1.26 KB
/
esbuild.js
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
// @ts-check
const esbuild = require('esbuild');
const path = require('node:path');
const os = require('node:os');
const { sassPlugin } = require('esbuild-sass-plugin');
/** @typedef {import('esbuild').BuildOptions} BuildOptions */
const args = process.argv.slice(2);
const CLIWatch = args.includes('--watch');
const CLIDevelopment = CLIWatch || args.includes('--development');
/** @type {BuildOptions} */
const commonConfig = {
bundle: true,
target: ['es2020'],
minify: !CLIDevelopment,
sourcemap: CLIDevelopment,
};
const srcDir = path.join(__dirname, 'src');
/** @type {BuildOptions[]} */
const configurations = [
{
entryPoints: [path.join(srcDir, 'memory', 'client', 'index.tsx')],
outfile: path.join(__dirname, 'dist', 'MemoryBrowser.js'),
plugins: [sassPlugin()],
format: 'iife',
platform: 'browser',
...commonConfig,
},
];
if (CLIWatch) {
(async function watch() {
await Promise.all(
configurations.map((config) =>
esbuild.context(config).then((context) => context.watch())
)
);
})();
} else {
(async function build() {
await Promise.all(
configurations.map((config) => esbuild.build(config))
);
})();
}