import process from 'node:process'; import builtins from 'builtin-modules'; import esbuild from 'esbuild'; const banner = `/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ `; const prod = process.argv[2] === 'production'; const context = await esbuild.context({ banner: { js: banner, }, bundle: true, entryNames: '[dir]/[name]', entryPoints: [ { in: 'src/main.ts', out: 'main' }, ], 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', ...builtins, ], format: 'cjs', loader: { '.css': 'css', '.mp3': 'dataurl', '.wav': 'dataurl', '.svg': 'text', '.tsx': 'tsx', '.jsx': 'jsx', }, logLevel: 'info', // outfile: "main.js", minify: false, outdir: '.', outExtension: { '.css': '.css' }, platform: 'browser', sourcemap: prod ? false : 'inline', target: 'es2018', treeShaking: true, jsx: 'automatic', jsxFactory: 'React.createElement', jsxFragment: 'React.Fragment', }); if (prod) { await context.rebuild(); process.exit(0); } else { await context.watch(); }