-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbundle.js
58 lines (50 loc) · 1.35 KB
/
bundle.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
const { existsSync, rmSync } = require("fs");
const esbuild = require("esbuild");
const outdir = "dist/";
const monacoBasePath = "monaco-editor/out/monaco-editor/esm/vs/";
const bundle = () => {
if (existsSync(outdir)) {
rmSync(outdir, { recursive: true, force: true });
}
/** @type {Partial<esbuild.BuildOptions>} */
const baseOptions = {
bundle: true,
minify: true,
target: "es2020",
sourcemap: false,
format: "iife",
define: { global: "window", "process.env.NODE_ENV": '"production"' },
};
// Monaco editor
esbuild.buildSync({
...baseOptions,
stdin: {
contents: `export * from "./monaco-editor/out/monaco-editor/esm/vs/editor/editor.main.js";`,
loader: "js",
resolveDir: ".",
sourcefile: "./monaco-editor.js",
},
loader: { ".ttf": "file" },
format: "esm",
outfile: outdir + "monaco-editor.js",
});
// Monaco editor workers
const entryFiles = [
"language/json/json.worker.js",
"language/css/css.worker.js",
"language/html/html.worker.js",
"language/typescript/ts.worker.js",
"editor/editor.worker.js",
].map((entry) => `${monacoBasePath}${entry}`);
entryFiles.forEach((entry) => {
esbuild.buildSync({
...baseOptions,
outdir,
entryPoints: [entry],
});
});
};
module.exports = bundle;
if (require.main === module) {
bundle();
}