-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.mjs
More file actions
39 lines (35 loc) · 1.47 KB
/
Copy pathbuild.mjs
File metadata and controls
39 lines (35 loc) · 1.47 KB
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
// Bundles the TypeScript sources into the extension/ folder. Each entry
// becomes one classic (IIFE) script — content scripts and MV3 pages can't
// use ES modules, and one file per context keeps the manifest simple.
import * as esbuild from "esbuild";
const watch = process.argv.includes("--watch");
const entries = [
{ in: "src/entries/content.ts", out: "extension/content.js" },
{ in: "src/entries/background.ts", out: "extension/background.js" },
{ in: "src/entries/offscreen.ts", out: "extension/offscreen/offscreen.js" },
{ in: "src/entries/youtube-main.ts", out: "extension/page/youtube-main.js" },
{ in: "src/entries/netflix-main.ts", out: "extension/page/netflix-main.js" },
{ in: "src/entries/popup.ts", out: "extension/popup/popup.js" },
{ in: "src/entries/options.ts", out: "extension/options/options.js" },
{ in: "src/entries/dashboard.ts", out: "extension/dashboard/dashboard.js" },
{ in: "src/entries/sync-bridge.ts", out: "extension/sync-bridge.js" }
];
const contexts = await Promise.all(entries.map((e) =>
esbuild.context({
entryPoints: [e.in],
outfile: e.out,
bundle: true,
format: "iife",
target: "chrome110",
sourcemap: false,
logLevel: "info"
})
));
if (watch) {
await Promise.all(contexts.map((c) => c.watch()));
console.log("watching for changes…");
} else {
await Promise.all(contexts.map((c) => c.rebuild()));
await Promise.all(contexts.map((c) => c.dispose()));
console.log(`built ${entries.length} bundles`);
}