esbuild.config.mjs 709 B

1234567891011121314151617181920212223242526272829303132
  1. import esbuild from "esbuild";
  2. import process from "node:process";
  3. const isProduction = process.argv.includes("production");
  4. const isDev = process.argv.includes("dev");
  5. const context = await esbuild.context({
  6. entryPoints: ["src/main.ts"],
  7. bundle: true,
  8. external: ["obsidian"],
  9. format: "cjs",
  10. target: "es2018",
  11. logLevel: "info",
  12. sourcemap: !isProduction,
  13. outfile: "main.js"
  14. });
  15. if (isProduction) {
  16. await context.rebuild();
  17. await context.dispose();
  18. process.exit(0);
  19. }
  20. if (isDev) {
  21. await context.watch();
  22. console.log("[image-stripper] 开发模式:正在监听构建变更(esbuild watch)");
  23. } else {
  24. await context.rebuild();
  25. await context.dispose();
  26. process.exit(0);
  27. }