29 lines
708 B
JavaScript
29 lines
708 B
JavaScript
// esbuild config — 打包 main.ts → main.js
|
|
import * as esbuild from "esbuild";
|
|
|
|
const isWatch = process.argv.includes("--watch");
|
|
|
|
const buildOptions = {
|
|
entryPoints: ["main.ts"],
|
|
bundle: true,
|
|
mainFields: ["browser", "module", "main"],
|
|
platform: "browser",
|
|
target: "es2020",
|
|
outfile: "main.js",
|
|
format: "cjs",
|
|
sourcemap: false,
|
|
minify: !isWatch,
|
|
external: ["obsidian"],
|
|
define: {
|
|
"process.env.NODE_ENV": isWatch ? '"development"' : '"production"',
|
|
},
|
|
};
|
|
|
|
if (isWatch) {
|
|
const ctx = await esbuild.context(buildOptions);
|
|
await ctx.watch();
|
|
console.log("Watching for changes...");
|
|
} else {
|
|
await esbuild.build(buildOptions);
|
|
console.log("Build complete: main.js");
|
|
} |