ObsidianSimpleTimeTracker/esbuild.config.mjs

61 lines
1.4 KiB
JavaScript
Raw Normal View History

2022-09-27 15:22:31 +02:00
import esbuild from "esbuild";
import process from "process";
2022-09-27 15:36:25 +02:00
import builtins from 'builtin-modules';
import { copy } from 'esbuild-plugin-copy';
2022-09-27 15:22:31 +02:00
2022-09-27 15:36:25 +02:00
const banner = `/*
2022-09-27 15:22:31 +02: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-09-27 15:36:25 +02:00
*/`;
2022-09-27 15:22:31 +02:00
const prod = (process.argv[2] === 'production');
esbuild.build({
banner: {
js: banner,
},
2022-09-27 15:36:25 +02:00
entryPoints: ['src/main.ts'],
2022-09-27 15:22:31 +02:00
bundle: true,
external: [
'obsidian',
'electron',
'@codemirror/autocomplete',
2022-09-27 15:36:25 +02:00
'@codemirror/closebrackets',
2022-09-27 15:22:31 +02:00
'@codemirror/collab',
'@codemirror/commands',
2022-09-27 15:36:25 +02:00
'@codemirror/comment',
'@codemirror/fold',
'@codemirror/gutter',
'@codemirror/highlight',
'@codemirror/history',
2022-09-27 15:22:31 +02:00
'@codemirror/language',
'@codemirror/lint',
2022-09-27 15:36:25 +02:00
'@codemirror/matchbrackets',
'@codemirror/panel',
'@codemirror/rangeset',
'@codemirror/rectangular-selection',
2022-09-27 15:22:31 +02:00
'@codemirror/search',
'@codemirror/state',
2022-09-27 15:36:25 +02:00
'@codemirror/stream-parser',
'@codemirror/text',
'@codemirror/tooltip',
2022-09-27 15:22:31 +02:00
'@codemirror/view',
2022-09-27 15:36:25 +02:00
...builtins
],
plugins: [
copy({
assets: [{
from: ["./manifest.json", "./main.js", "./styles.css"],
to: ["./test-vault/.obsidian/plugins/obsidian-simple-time-tracker/."]
}]
}),
],
2022-09-27 15:22:31 +02:00
format: 'cjs',
watch: !prod,
2022-09-27 15:36:25 +02:00
target: 'es2016',
2022-09-27 15:22:31 +02:00
logLevel: "info",
sourcemap: prod ? false : 'inline',
treeShaking: true,
outfile: 'main.js',
}).catch(() => process.exit(1));