Skip to content

Commit

Permalink
feat: switch to esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Jan 21, 2022
1 parent cc813e7 commit 766bb45
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 166 deletions.
70 changes: 70 additions & 0 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import esbuild from "esbuild";
import process from "process";
import builtins from "builtin-modules";
import sveltePlugin from "esbuild-svelte";
import sveltePreprocess from "svelte-preprocess";
import inlineWorkerPlugin from "esbuild-plugin-inline-worker";
import { config } from "dotenv";

config();

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;

esbuild
.build({
banner: {
js: banner
},
entryPoints: ["src/main.ts", "src/styles.css"],
bundle: true,
external: [
"obsidian",
"electron",
"codemirror",
"@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: "es2020",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
outdir: dir,
plugins: [
sveltePlugin({
compilerOptions: { css: true },
preprocess: sveltePreprocess()
}),
inlineWorkerPlugin(/* { format: "cjs" } */)
]
})
.catch(() => process.exit(1));
Loading

0 comments on commit 766bb45

Please sign in to comment.