-
Notifications
You must be signed in to change notification settings - Fork 18
/
esbuild.config.mjs
58 lines (53 loc) · 1.53 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
53
54
55
56
57
58
import esbuild from "esbuild";
import process from "process";
import builtins from "builtin-modules";
import fs from "fs";
import inlineWorkerPlugin from "esbuild-plugin-inline-worker";
// Build the primary javascript file.
async function build(prod) {
fs.mkdirSync("build/plugin", { recursive: true });
const result = await esbuild.build({
banner: {
js: `/* Datacore: Autogenerated ESBuild file. See https://github.com/blacksmithgu/datacore for source. */`,
},
entryPoints: ['src/main.ts'],
bundle: true,
metafile: true,
plugins: [ inlineWorkerPlugin({ workerName: "Datacore Indexer" }) ],
external: [
'obsidian',
'electron',
'@codemirror/autocomplete',
'@codemirror/collab',
'@codemirror/commands',
'@codemirror/language',
'@codemirror/lint',
'@codemirror/search',
'@codemirror/state',
'@codemirror/view',
'@lezer/common',
'@lezer/highlight',
'@lezer/lr',
"pdfjs-dist",
...builtins],
alias: {
"react": "preact/compat"
},
format: 'cjs',
target: 'es2018',
logLevel: "info",
sourcemap: prod ? false : 'inline',
treeShaking: true,
alias: {
react: "preact/compat",
"react-dom": "preact/compat"
},
outfile: 'build/plugin/main.js',
}).catch(() => process.exit(1));
// Copy the manifest and styles.
fs.copyFileSync("manifest-beta.json", "build/plugin/manifest.json");
fs.renameSync("build/plugin/main.css", "build/plugin/styles.css");
fs.writeFileSync("build/meta.json", JSON.stringify(result.metafile));
}
// Run the build.
build(process.argv[2] === 'production');