heekangpark_obsidian-hk-cod.../esbuild.config.mjs

65 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2023-01-30 05:37:44 +00:00
import esbuild from "esbuild";
import process from "process";
import builtins from "builtin-modules";
2023-02-10 22:02:20 +00:00
import { copyFile } from "fs/promises";
2023-02-08 09:14:46 +00:00
import { sassPlugin } from "esbuild-sass-plugin";
2023-01-30 05:37:44 +00:00
const banner =
2023-02-08 09:14:46 +00:00
`/*
2023-01-30 05:37:44 +00:00
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 context = await esbuild.context({
banner: {
js: banner,
},
2023-02-08 09:14:46 +00:00
entryPoints: [
"./src/styles.scss",
"./src/main.ts"
],
2023-01-30 05:37:44 +00:00
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",
target: "es2018",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
2023-02-08 09:14:46 +00:00
outdir: "./dist",
2023-02-10 22:02:20 +00:00
plugins: [
sassPlugin(),
{
name: "copy-build-files-to-root",
setup(build) {
build.onEnd(() => {
copyFile("./dist/main.js", "./main.js");
copyFile("./dist/styles.css", "./styles.css");
});
}
}
]
2023-01-30 05:37:44 +00:00
});
if (prod) {
await context.rebuild();
process.exit(0);
} else {
await context.watch();
}