-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mjs
40 lines (34 loc) · 950 Bytes
/
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
import esbuild from "esbuild";
const entryPoints = [
"Resources/Private/Assets/*.js",
"Resources/Private/Assets/Custom/*.ts",
"Resources/Private/Assets/Plugins/*.js",
"Resources/Private/Assets/UI/*.js",
];
const baseOptions = {
logLevel: "info",
bundle: true,
minify: process.argv.includes("--production"),
sourcemap: !process.argv.includes("--production"),
target: "es2020",
entryPoints,
legalComments: "none",
};
const scriptOptions = {
...baseOptions,
outdir: "Resources/Public/Scripts",
format: "iife",
};
const moduleOptions = {
...baseOptions,
outdir: "Resources/Public/Modules",
format: "esm",
splitting: true,
};
async function watch(options) {
const context = await esbuild.context(options);
await context.watch();
}
[scriptOptions, moduleOptions].forEach((options) => {
process.argv.includes("--watch") ? watch(options) : esbuild.build(options);
});