-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
36 lines (33 loc) · 1.18 KB
/
build.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
const esbuild = require('esbuild');
const fs = require('fs');
const path = require('path');
// Define the output folder
const outputFolder = path.resolve(__dirname, 'out');
// Function to clean the output folder if it exists
async function cleanOutputFolder() {
if (fs.existsSync(outputFolder)) {
await fs.promises.rm(outputFolder, { recursive: true, force: true });
console.log('Output folder cleaned.');
}
}
// Run the cleaning function and then the esbuild process
cleanOutputFolder().then(() => {
esbuild.build({
entryPoints: ['src/extension.ts'], // Your entry file
bundle: true,
outfile: 'out/extension.js',
external: ['vscode'], // Mark vscode as external
platform: 'node', // Ensures the output is suitable for Node.js
target: 'node14', // Set your desired Node.js version
sourcemap: false,
minify: true, // Optionally minify the output
}).then(() => {
console.log('Build completed successfully.');
}).catch(() => {
console.error('Build failed.');
process.exit(1);
});
}).catch((err) => {
console.error('Error cleaning output folder:', err);
process.exit(1);
});