-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuild.js
More file actions
33 lines (29 loc) · 1.06 KB
/
build.js
File metadata and controls
33 lines (29 loc) · 1.06 KB
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
const { nativeNodeModulesPlugin } = require("esbuild-native-node-modules-plugin");
const { platform } = require("os");
// Parse command line arguments
const args = process.argv.slice(2);
const shouldMinify = args.includes('--minify');
const shouldGenerateSourcemap = args.includes('--sourcemap');
const shouldWatch = args.includes('--watch');
const buildOptions = {
sourcemap: shouldGenerateSourcemap,
minify: shouldMinify,
entryPoints: ['./src/extension.ts'],
bundle: true,
outfile: 'out/extension.js',
plugins: platform=="win32"?[nativeNodeModulesPlugin]:[],
external: ['vscode', '*.node'], // Treat .node files as external
format:'cjs',
platform:'node',
loader: { '.node': 'file' }, // Loader for .node files
//loader: { '.png': 'binary' },
};
if (shouldWatch) {
buildOptions.watch = {
onRebuild(error, result) {
if (error) console.error('Watch build failed:', error);
else console.log('Watch build succeeded');
}
};
}
require('esbuild').build(buildOptions).catch(() => process.exit(1))