-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathesbuild.config.mjs
52 lines (49 loc) · 1.19 KB
/
esbuild.config.mjs
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
import obPlugin from "./scripts/ob.esbuild.mjs";
import { build } from "esbuild";
import { join, resolve } from "path";
const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source visit the plugins github repository
*/
`;
const isProd = process.env.BUILD === "production";
try {
await build({
entryPoints: ["src/chsp-main.ts"],
bundle: true,
watch: !isProd,
platform: "browser",
external: [
"obsidian",
"@codemirror/state",
"@codemirror/view",
"path",
"fs/promises",
"@electron/remote",
],
format: "cjs",
mainFields: ["browser", "module", "main"],
banner: { js: banner },
sourcemap: isProd ? false : "inline",
minify: isProd,
define: {
"process.env.NODE_ENV": JSON.stringify(process.env.BUILD),
},
outfile: "build/main.js",
plugins: [
obPlugin(),
{
name: "cm6-src",
setup: (build) =>
build.onResolve({ filter: /^cm6-view-src/ }, (args) => {
return {
path: resolve(join("node_modules", args.path + ".ts")),
};
}),
},
],
});
} catch (err) {
console.error(err);
process.exit(1);
}