Skip to content

Commit

Permalink
chore: switch to esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Jan 30, 2023
1 parent e9cefd5 commit a494c75
Show file tree
Hide file tree
Showing 18 changed files with 2,029 additions and 38 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ dist
rollup.config-dev.js
.hotreload
webpack.dev.js

.env
56 changes: 56 additions & 0 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import esbuild from "esbuild";
import process from "process";
import builtins from "builtin-modules";
import inlineWorkerPlugin from "esbuild-plugin-inline-worker";
import { replace } from "esbuild-plugin-replace";
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/autocomplete",
"@codemirror/collab",
"@codemirror/commands",
"@codemirror/language",
"@codemirror/lint",
"@codemirror/search",
"@codemirror/state",
"@codemirror/view",
"@lezer/common",
"@lezer/highlight",
"@lezer/lr",
...builtins
],
format: "cjs",
watch: !prod,
target: "es2020",
logLevel: "info",
sourcemap: prod ? false : "inline",
minify: prod,
treeShaking: true,
outdir: dir,
loader: { ".png": "base64" },
plugins: [inlineWorkerPlugin()]
})
.catch(() => {
process.exit(1);
});
Loading

0 comments on commit a494c75

Please sign in to comment.