esbuild.config.mjs (953B)
1 import esbuild from "esbuild"; 2 import process from "process"; 3 import builtins from "builtin-modules"; 4 5 const banner = 6 `/* 7 THIS IS A GENERATED/BUNDLED FILE BY ESBUILD 8 if you want to view the source, please visit the github repository of this plugin 9 */ 10 `; 11 12 const prod = (process.argv[2] === "production"); 13 14 const context = await esbuild.context({ 15 banner: { 16 js: banner, 17 }, 18 entryPoints: ["main.ts"], 19 bundle: true, 20 external: [ 21 "obsidian", 22 "electron", 23 "@codemirror/autocomplete", 24 "@codemirror/collab", 25 "@codemirror/commands", 26 "@codemirror/language", 27 "@codemirror/lint", 28 "@codemirror/search", 29 "@codemirror/state", 30 "@codemirror/view", 31 "@lezer/common", 32 "@lezer/highlight", 33 "@lezer/lr", 34 ...builtins], 35 format: "cjs", 36 target: "es2018", 37 logLevel: "info", 38 sourcemap: prod ? false : "inline", 39 treeShaking: true, 40 outfile: "main.js", 41 }); 42 43 if (prod) { 44 await context.rebuild(); 45 process.exit(0); 46 } else { 47 await context.watch(); 48 }