forked from NebulaServices/Dynamic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.dev.js
72 lines (59 loc) · 1.41 KB
/
esbuild.dev.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import * as esbuild from "esbuild";
import { copyFile } from "fs/promises";
await import("./index.js");
console.time("esbuild");
const worker = await esbuild.context({
entryPoints: ["lib/worker/index.ts"],
bundle: true,
outfile: "dist/dynamic.worker.js",
format: "iife",
minify: true,
platform: "browser",
sourcemap: true,
target: ["es2020"],
plugins: [],
metafile: true,
});
worker.watch();
const handler = await esbuild.context({
entryPoints: ["lib/handler/index.ts"],
bundle: true,
outfile: "dist/dynamic.handler.js",
format: "iife",
minify: true,
platform: "browser",
sourcemap: true,
target: ["es2020"],
plugins: [],
metafile: true,
});
handler.watch();
const client = await esbuild.context({
entryPoints: ["lib/client/index.ts"],
bundle: true,
outfile: "dist/dynamic.client.js",
format: "iife",
minify: true,
platform: "browser",
sourcemap: true,
target: ["es2020"],
plugins: [],
metafile: true,
});
client.watch();
const html = await esbuild.context({
entryPoints: ["lib/html/index.ts"],
bundle: true,
outfile: "dist/dynamic.html.js",
format: "iife",
minify: true,
platform: "browser",
sourcemap: true,
target: ["es2020"],
plugins: [],
metafile: true,
});
html.watch();
await copyFile("./lib/dynamic.config.js", "./dist/dynamic.config.js");
console.log(await esbuild.analyzeMetafile((await worker.rebuild()).metafile));
console.timeEnd("esbuild");