mirror of
https://github.com/fancive/obsidian-parallel-reader.git
synced 2026-07-22 17:20:24 +00:00
Generates main.js.map alongside main.js so error stack traces in the Obsidian developer console point to original source locations. Change-Id: I3f63196bfa421c2ac69aee371e4c294d42ee629c
36 lines
742 B
JavaScript
36 lines
742 B
JavaScript
import esbuild from 'esbuild';
|
|
import { builtinModules } from 'module';
|
|
|
|
const production = process.argv[2] === 'production';
|
|
const watch = process.argv[2] === 'watch';
|
|
|
|
const external = [
|
|
'obsidian',
|
|
'electron',
|
|
...builtinModules,
|
|
...builtinModules.map(m => `node:${m}`),
|
|
];
|
|
|
|
const context = await esbuild.context({
|
|
entryPoints: ['main.ts'],
|
|
bundle: true,
|
|
platform: 'node',
|
|
format: 'cjs',
|
|
target: 'es2022',
|
|
external,
|
|
sourcemap: production ? 'linked' : 'inline',
|
|
treeShaking: true,
|
|
minify: production,
|
|
outfile: 'main.js',
|
|
banner: {
|
|
js: "'use strict';",
|
|
},
|
|
});
|
|
|
|
if (watch) {
|
|
await context.watch();
|
|
console.log('Watching for changes...');
|
|
} else {
|
|
await context.rebuild();
|
|
await context.dispose();
|
|
}
|