-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathembeds.js
47 lines (42 loc) · 1.12 KB
/
embeds.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
import * as path from "node:path";
import * as esbuild from "esbuild";
const targets = [
["./src/embed/enhance.js", "build/embed", "enhance.js"] /* page embeds */,
["./src/embed/noteLoader.js", "build/notes", "loader.js"] /* node embed */,
[
"./src/embed/documentLoader.js",
"build/viewer",
"loader.js",
] /* document embed */,
[
"./src/embed/projectLoader.js",
"build/embed",
"loader.js",
] /* was search embed, but now only project embeds */,
];
async function build(src, dir, filename) {
return esbuild.build({
entryPoints: [src],
bundle: true,
outfile: path.join(dir, filename),
platform: "browser",
format: "iife",
logLevel: "info",
treeShaking: true,
define: {
"process.env.NODE_ENV": JSON.stringify(
process.env.NODE_ENV ?? "production",
),
"process.env.DEPLOY_PRIME_URL": JSON.stringify(
process.env.DEPLOY_PRIME_URL ?? "",
),
},
});
}
async function main() {
const promises = targets.map(async ([src, dir, filename]) =>
build(src, dir, filename),
);
return Promise.all(promises);
}
main().catch(console.error);