diff --git a/esbuild.config.mjs b/esbuild.config.mjs index a902edc..1cb393d 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -37,29 +37,31 @@ const buildOptions = { ...builtins, ], format: "cjs", - watch: !prod, target: "es2018", logLevel: "info", sourcemap: prod ? false : "inline", treeShaking: true, }; -esbuild - .build(buildOptions) - .catch(() => process.exit(1)) - .then(() => { - /** - * If there is a new version number, copy it to the dist folder - */ - if (process.env.npm_new_version) { - const manifestJsonSrc = path.join(process.cwd(), "manifest.json"); - const manifestJsonDist = path.join( - process.cwd(), - buildOptions.outdir, - "manifest.json" - ); +const context = await esbuild.context(buildOptions); - // Copy the manifest.json file over to the dist folder - copyFileSync(manifestJsonSrc, manifestJsonDist); - } - }); +if (prod) { + await context.rebuild(); + /** + * If there is a new version number, copy it to the dist folder + */ + if (process.env.npm_new_version) { + const manifestJsonSrc = path.join(process.cwd(), "manifest.json"); + const manifestJsonDist = path.join( + process.cwd(), + buildOptions.outdir, + "manifest.json" + ); + + // Copy the manifest.json file over to the dist folder + copyFileSync(manifestJsonSrc, manifestJsonDist); + } + process.exit(0); +} else { + await context.watch(); +} diff --git a/package.json b/package.json index 639ef2c..9d67c52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-sample-plugin", - "version": "1.0.1", + "version": "1.0.0", "description": "This is a sample plugin for Obsidian (https://obsidian.md)", "main": "main.js", "scripts": { @@ -16,7 +16,7 @@ "@typescript-eslint/eslint-plugin": "5.29.0", "@typescript-eslint/parser": "5.29.0", "builtin-modules": "3.3.0", - "esbuild": "0.14.47", + "esbuild": "0.17.3", "obsidian": "latest", "tslib": "2.4.0", "typescript": "4.7.4"