-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.js
57 lines (49 loc) · 1.4 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
49
50
51
52
53
54
55
56
57
// Derived from https://github.com/microsoft/vscode-anycode/blob/82850955c5893258c5c3381e3d4d116bc34086d5/anycode/esbuild.js
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const esbuild = require('esbuild')
let watch;
if (process.argv.includes('--watch')) {
watch = {
onRebuild(error, result) {
if (error) {
console.error('watch build failed:', error);
} else {
console.log('watch build succeeded');
}
}
}
}
const clientBuildOptions = {
bundle: true,
external: ['vscode'],
target: 'es2020',
format: 'cjs',
watch
}
const browserClient = esbuild.build({
...clientBuildOptions,
entryPoints: ['src/extension.ts'],
outfile: 'dist/delores-dev-dev.extension.browser.js',
}).catch((e) => {
console.error(e)
});
const nodeClient = esbuild.build({
...clientBuildOptions,
platform: 'node',
entryPoints: ['src/extension.ts'],
outfile: 'dist/delores-dev-dev.extension.node.js',
}).catch((e) => {
console.error(e)
});
Promise.all([
browserClient, nodeClient
]).then(() => {
if (watch) {
console.log('done building, watching for file changes')
} else {
console.log('done building')
}
})