-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathesbuild.config.ts
55 lines (49 loc) · 1.35 KB
/
esbuild.config.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { context } from "esbuild";
import { sassPlugin } from "esbuild-sass-plugin";
import { existsSync } from "node:fs";
import { rm } from "node:fs/promises";
import { args } from "./tools/args-parser.js";
import templatePathsPromise from "./tools/get-template-paths.js";
const templatePaths = await templatePathsPromise;
const development = Object.hasOwn(args, "development");
console.log(
`Building Forbidden Lands for ${development ? "development" : "production"}...`,
);
if (existsSync("./forbidden-lands.js")) await rm("./forbidden-lands.js");
if (existsSync("./forbidden-lands.css")) await rm("./forbidden-lands.css");
const ctx = await context({
bundle: true,
entryPoints: ["./src/forbidden-lands.ts", "./src/forbidden-lands.scss"],
outdir: "./",
format: "iife",
logLevel: "info",
sourcemap: development ? "inline" : false,
ignoreAnnotations: development,
minifyWhitespace: true,
minifySyntax: true,
drop: development ? [] : ["console", "debugger"],
define: {
GLOBALPATHS: JSON.stringify(templatePaths),
},
plugins: [
sassPlugin({
logger: {
warn: () => "",
},
}),
{
name: "external-files",
setup(inBuild) {
inBuild.onResolve(
{ filter: /(\.\/assets|\.\/fonts|\/systems)/ },
() => {
return { external: true };
},
);
},
},
],
});
ctx.rebuild();
if (development) ctx.watch();
else ctx.dispose();