Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle.js
More file actions
Latest commit
34 lines (30 loc) · 821 Bytes
/
Copy pathbundle.js
File metadata and controls
34 lines (30 loc) · 821 Bytes
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
import{build}from"esbuild";
import{minify}from"terser";
importfsfrom"node:fs";
asyncfunctionbundle(){
// 1. Basic lib.js
awaitbuild({
entryPoints: ["src/main.ts"],
outfile: "dist/src-js/lib.js",
bundle: true,
format: "esm",
sourcemap: true,
});
// 2. Full bundle (could include all dependencies)
awaitbuild({
entryPoints: ["src/main.ts"],
outfile: "dist/src-js/lib.full.js",
bundle: true,
format: "esm",
sourcemap: true,
minify: false,
});
// 3. Minified version
constjs=fs.readFileSync("dist/src-js/lib.full.js","utf-8");
constminified=awaitminify(js,{sourceMap: {filename: "lib-min.js"}});
fs.writeFileSync("dist/src-js/lib-min.js",minified.code);
}
bundle().catch(err=>{
console.error(err);
process.exit(1);
});