-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.ts
executable file
·38 lines (35 loc) · 908 Bytes
/
build.ts
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
#!/usr/bin/env zx
import "zx/globals";
import esbuild from "esbuild";
import { sassPlugin } from "esbuild-sass-plugin";
void (async () => {
if (argv.target === "style") {
await buildStyles();
}
})();
async function buildStyles() {
try {
const options: esbuild.BuildOptions = {
bundle: true,
entryPoints: ["src/extension.preview.scss"],
plugins: [sassPlugin()],
outfile: "dist/extension.preview.css",
metafile: true,
logLevel: "info",
minify: argv.minify,
};
if (argv.watch) {
const ctx = await esbuild.context(options);
await ctx.watch();
const result = await ctx.rebuild();
if (result.metafile) {
const metafileMessages = await esbuild.analyzeMetafile(result.metafile);
echo(metafileMessages);
}
} else {
await esbuild.build(options);
}
} catch (error) {
echo(error);
}
}