-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.mjs
57 lines (54 loc) · 1.46 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
51
52
53
54
55
56
57
import esbuild from "esbuild";
import clear from "esbuild-plugin-clear";
import copy from "esbuild-plugin-copy";
import esbuildSvelte from "esbuild-svelte";
import sveltePreprocess from "svelte-preprocess";
const [node_, program_, ...args_] = process.argv;
const args = new Set(args_);
const options = {
logLevel: "info",
format: "iife",
entryPoints: [
"./src/content/content.ts",
"./src/background/background.ts",
"./src/options/options.ts"
],
bundle: true,
minify: !args.has("dev"),
sourcemap: true,
outdir: "dist",
plugins: [
clear("./dist"),
copy({
resolveFrom: "cwd",
assets: [
{
from: "./static/assets/*",
to: "./dist/assets"
},
{
from: "./manifest.json",
to: "./dist/manifest.json"
},
{
from: "./src/Options/options.html",
to: "./dist/Options/options.html"
}
]
}),
esbuildSvelte({
preprocess: sveltePreprocess(),
compilerOptions: {
hydratable: false,
css: "external",
dev: args.has("dev")
}
})
]
};
if (args.has("watch")) {
const context = await esbuild.context(options)
await context.watch();
} else {
await esbuild.build(options);
}