ObsidianCustomFrames/esbuild.config.mjs

61 lines
1.4 KiB
JavaScript
Raw Normal View History

2022-03-19 20:21:16 +01:00
import esbuild from "esbuild";
import process from "process";
2022-03-29 13:19:33 +02:00
import builtins from 'builtin-modules';
2022-08-21 17:37:20 +02:00
import { copy } from 'esbuild-plugin-copy';
2022-03-19 20:21:16 +01:00
2022-03-29 13:19:33 +02:00
const banner = `/*
2022-03-19 20:21:16 +01:00
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
2022-03-29 13:19:33 +02:00
*/`;
2022-03-19 20:21:16 +01:00
const prod = (process.argv[2] === 'production');
esbuild.build({
banner: {
js: banner,
},
2022-03-29 13:18:25 +02:00
entryPoints: ['src/main.ts'],
2022-03-19 20:21:16 +01:00
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',
2022-03-29 13:18:25 +02:00
...builtins
],
2022-08-21 17:37:20 +02:00
plugins: [
copy({
assets: [{
from: ["./manifest.json", "./main.js", "./styles.css"],
to: ["./test-vault/.obsidian/plugins/obsidian-custom-frames/."]
}]
}),
],
2022-03-19 20:21:16 +01:00
format: 'cjs',
watch: !prod,
target: 'es2016',
logLevel: "info",
sourcemap: prod ? false : 'inline',
treeShaking: true,
outfile: 'main.js',
}).catch(() => process.exit(1));