noteshare.space/plugin/esbuild.config.mjs

64 lines
1.4 KiB
JavaScript
Raw Normal View History

2022-06-18 17:51:45 +03:00
import esbuild from "esbuild";
import process from "process";
2022-06-26 23:46:39 +03:00
import builtins from "builtin-modules";
2022-06-18 17:51:45 +03:00
2022-06-29 12:18:32 +03:00
import esbuildSvelte from "esbuild-svelte";
import sveltePreprocess from "svelte-preprocess";
2022-06-26 23:46:39 +03:00
const banner = `/*
2022-06-18 17:51:45 +03: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-06-26 23:46:39 +03:00
const prod = process.argv[2] === "production";
2022-06-18 17:51:45 +03:00
2022-06-26 23:46:39 +03:00
esbuild
.build({
banner: {
js: banner,
},
entryPoints: ["main.ts"],
bundle: true,
2022-06-29 12:18:32 +03:00
plugins: [
esbuildSvelte({
compilerOptions: { css: true },
preprocess: sveltePreprocess(),
}),
],
2022-06-26 23:46:39 +03:00
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",
...builtins,
],
format: "cjs",
watch: !prod,
target: "es2016",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
outfile: "main.js",
})
.catch(() => process.exit(1));