Skip to content

Commit

Permalink
Fix esbuild configuration for watch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
MunGell committed Jun 15, 2024
1 parent 005d097 commit 0e3335e
Showing 1 changed file with 39 additions and 37 deletions.
76 changes: 39 additions & 37 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 0e3335e

Please sign in to comment.