mirror of
https://github.com/ebullient/obsidian-deck-notes.git
synced 2026-07-22 06:40:43 +00:00
57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
import esbuild from "esbuild";
|
|
import process from "node:process";
|
|
import { builtinModules } from "node:module";
|
|
|
|
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 dir = prod || !process.env.OUTDIR ? "./build" : process.env.OUTDIR;
|
|
|
|
const parameters = {
|
|
banner: {
|
|
js: banner,
|
|
},
|
|
entryPoints: ['src/main.ts', 'src/styles.css'],
|
|
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',
|
|
...builtinModules
|
|
],
|
|
format: 'cjs',
|
|
logLevel: 'info',
|
|
target: 'es2020',
|
|
treeShaking: true,
|
|
sourcemap: prod ? false : 'inline',
|
|
minify: prod,
|
|
outdir: dir,
|
|
};
|
|
|
|
if (prod) {
|
|
await esbuild.build(parameters).catch((x) => {
|
|
if (x.errors) {
|
|
console.error(x.errors);
|
|
} else {
|
|
console.error(x);
|
|
}
|
|
process.exit(1)
|
|
});
|
|
} else {
|
|
const ctx = await esbuild.context(parameters);
|
|
await ctx.watch()
|
|
}
|