Skip to content

Commit

Permalink
update build script
Browse files Browse the repository at this point in the history
  • Loading branch information
jparkerweb committed Oct 9, 2024
1 parent bcc1721 commit e705c7e
Show file tree
Hide file tree
Showing 3 changed files with 263 additions and 190 deletions.
73 changes: 39 additions & 34 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,44 @@ import builtins from "builtin-modules";

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
*/
`;
This is a sample banner
*/`;

const prod = (process.argv[2] === 'production');
const prod = process.argv[2] === "production";

esbuild.build({
banner: {
js: banner,
},
entryPoints: ['src/main.js'],
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: 'es2018',
logLevel: "info",
sourcemap: prod ? false : 'inline',
treeShaking: true,
outfile: 'main.js',
}).catch(() => process.exit(1));
const context = await esbuild.context({
banner: {
js: banner,
},
entryPoints: ["src/main.js"], // Updated to point to the correct file
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,
outfile: "main.js",
});

if (prod) {
await context.rebuild();
process.exit(0);
} else {
await context.watch();
}
Loading

0 comments on commit e705c7e

Please sign in to comment.