forked from jasonwilliams/anki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mjs
50 lines (48 loc) · 1.1 KB
/
build.mjs
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
const production = process.argv[2] === "--production";
import { copy } from "esbuild-plugin-copy";
import { sassPlugin } from "esbuild-sass-plugin";
import esbuild from "esbuild";
const watch = process.argv[2] === "--watch";
const context = await esbuild
.context({
entryPoints: ["./src/extension.ts"],
bundle: true,
outdir: "out",
external: ["vscode"],
format: "cjs",
sourcemap: !production,
minify: production,
platform: "node",
plugins: [
copy({
resolveFrom: "cwd",
assets: {
from: ["./src/resources/icons/**/*.svg"],
to: ["./out/resources/icons/"],
},
keepStructure: true,
verbose: false,
}),
sassPlugin(),
{
name: "watch",
setup(build) {
build.onEnd(() => {
console.log("build finished");
});
build.onStart(() => {
console.log("building");
});
},
},
],
})
.catch((e) => {
console.error(e);
process.exit(1);
});
if (watch) {
await context.watch();
} else {
context.dispose();
}