-
Notifications
You must be signed in to change notification settings - Fork 4
/
.build.js
55 lines (52 loc) · 1.3 KB
/
.build.js
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
/** Build script to use esbuild without specifying 1000 CLI options */
const { build, cliopts } = require("estrella");
const glob = require("tiny-glob");
const [opts, args] = cliopts.parse(
["react", "Build React sources"],
["typescript", "Build TypeScript sources"],
);
if (opts.react) {
(async () => {
let entryPoints = await glob("./admin/src/*.tsx");
entryPoints = entryPoints.filter(
(ep) => !ep.endsWith(".d.ts") && !ep.endsWith(".test.tsx"),
);
await build({
entryPoints,
tsconfig: "./admin/tsconfig.json",
bundle: true,
splitting: true,
format: "esm",
minify: !cliopts.watch,
outdir: "admin/build",
sourcemap: true,
// sourcesContent: true,
logLevel: "info",
define: {
"process.env.NODE_ENV": cliopts.watch
? '"development"'
: '"production"',
},
});
})().catch(() => process.exit(1));
}
if (opts.typescript) {
(async () => {
let entryPoints = await glob("./src/**/*.ts");
entryPoints = entryPoints.filter(
(ep) => !ep.endsWith(".d.ts") && !ep.endsWith(".test.ts"),
);
await build({
entryPoints,
tsconfig: "./tsconfig.build.json",
outdir: "build",
bundle: false,
minify: false,
sourcemap: true,
logLevel: "info",
platform: "node",
format: "cjs",
target: "node12",
});
})().catch(() => process.exit(1));
}