diff --git a/esbuild.config.mjs b/esbuild.config.mjs index 84351f1..bf35c1b 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -3,43 +3,45 @@ import process from "process"; import builtins from 'builtin-modules' const prod = (process.argv[2] === 'production'); - -let ctx = await esbuild.context({ - entryPoints: ['src/main.ts'], - bundle: true, - external: [ - 'obsidian', - 'electron', - '@codemirror/autocomplete', - '@codemirror/closebrackets', - '@codemirror/collab', - '@codemirror/commands', - '@codemirror/comment', - '@codemirror/fold', - '@codemirror/gutter', - '@codemirror/highlight', - '@codemirror/history', - '@codemirror/language', - '@codemirror/lint', - '@codemirror/matchbrackets', - '@codemirror/panel', - '@codemirror/rangeset', - '@codemirror/rectangular-selection', - '@codemirror/search', - '@codemirror/state', - '@codemirror/stream-parser', - '@codemirror/text', - '@codemirror/tooltip', - '@codemirror/view', - ...builtins], - format: 'cjs', - target: 'es2016', - logLevel: "info", - sourcemap: prod ? false : 'inline', - treeShaking: true, - outfile: 'main.js', -}).catch(() => process.exit(1)); +const args = { + entryPoints: ['src/main.ts'], + bundle: true, + external: [ + 'obsidian', + 'electron', + '@codemirror/autocomplete', + '@codemirror/closebrackets', + '@codemirror/collab', + '@codemirror/commands', + '@codemirror/comment', + '@codemirror/fold', + '@codemirror/gutter', + '@codemirror/highlight', + '@codemirror/history', + '@codemirror/language', + '@codemirror/lint', + '@codemirror/matchbrackets', + '@codemirror/panel', + '@codemirror/rangeset', + '@codemirror/rectangular-selection', + '@codemirror/search', + '@codemirror/state', + '@codemirror/stream-parser', + '@codemirror/text', + '@codemirror/tooltip', + '@codemirror/view', + ...builtins], + format: 'cjs', + target: 'es2016', + logLevel: "info", + sourcemap: false, + treeShaking: true, + outfile: 'main.js', +} if (!prod) { - await ctx.watch() + args.sourcemap = 'inline'; + await (await esbuild.context(args)).watch() +} else { + await esbuild.build(args); }