lenalebt_obsidian-pocketboo.../esbuild.config.mjs

49 lines
1,010 B
JavaScript
Raw Normal View History

2023-01-28 07:43:15 +00:00
import esbuild from 'esbuild';
import process from 'process';
import builtins from 'builtin-modules';
2023-01-26 20:58:49 +00:00
2023-01-28 07:43:15 +00:00
const banner = `/*
2023-01-26 20:58:49 +00:00
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;
2023-01-28 07:43:15 +00:00
const prod = process.argv[2] === 'production';
2023-01-26 20:58:49 +00:00
const context = await esbuild.context({
2023-01-28 07:43:15 +00:00
banner: {
js: banner,
},
entryPoints: ['src/main.ts'],
bundle: true,
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',
target: 'es2018',
logLevel: 'info',
sourcemap: prod ? false : 'inline',
treeShaking: true,
outfile: 'build/main.js',
2023-01-26 20:58:49 +00:00
});
if (prod) {
2023-01-28 07:43:15 +00:00
await context.rebuild();
process.exit(0);
2023-01-26 20:58:49 +00:00
} else {
2023-01-28 07:43:15 +00:00
await context.watch();
}