-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.js
More file actions
58 lines (51 loc) · 1.28 KB
/
Copy pathesbuild.js
File metadata and controls
58 lines (51 loc) · 1.28 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const esbuild = require('esbuild');
const fs = require('fs');
const path = require('path');
const watch = process.argv.includes('--watch');
function copyStatic() {
const mediaOut = path.join(__dirname, 'out', 'media');
fs.mkdirSync(mediaOut, { recursive: true });
fs.copyFileSync(
path.join(__dirname, 'src', 'media', 'view.css'),
path.join(mediaOut, 'view.css')
);
fs.copyFileSync(
path.join(__dirname, 'src', 'media', 'view.js'),
path.join(mediaOut, 'view.js')
);
const wasmSrc = require.resolve(
'node-sqlite3-wasm/dist/node-sqlite3-wasm.wasm'
);
fs.copyFileSync(
wasmSrc,
path.join(__dirname, 'out', 'node-sqlite3-wasm.wasm')
);
}
/** @type {import('esbuild').BuildOptions} */
const buildOptions = {
entryPoints: ['src/extension.ts'],
bundle: true,
outfile: 'out/extension.js',
external: ['vscode'],
format: 'cjs',
platform: 'node',
target: 'node18',
sourcemap: true,
minify: !watch,
logLevel: 'info',
};
async function main() {
copyStatic();
if (watch) {
const ctx = await esbuild.context(buildOptions);
await ctx.watch();
console.log('watching…');
} else {
await esbuild.build(buildOptions);
console.log('build complete');
}
}
main().catch((err) => {
console.error(err);
process.exit(1);
});