Use ESBuild API instead of passing command line arguments (#16)

This commit is contained in:
Phillip 2021-10-25 17:45:15 +02:00 committed by GitHub
parent e013825c21
commit 02ac033b15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 18 deletions

27
esbuild.config.mjs Normal file
View File

@ -0,0 +1,27 @@
import esbuild from "esbuild";
import process from "process";
const banner =
`/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source visit the plugins github repository
*/
`;
const prod = (process.argv[2] === 'production');
esbuild.build({
banner: {
js: banner,
},
entryPoints: ['main.ts'],
bundle: true,
external: ['obsidian'],
format: 'cjs',
watch: !prod,
target: 'es2016',
logLevel: "info",
sourcemap: prod ? false : 'inline',
treeShaking: true,
outfile: 'main.js',
}).catch(() => process.exit(1));

View File

@ -4,8 +4,8 @@
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
"main": "main.js",
"scripts": {
"dev": "esbuild main.ts --bundle --external:obsidian --outdir=. --target=es2016 --format=cjs --sourcemap=inline --watch",
"build": "esbuild main.ts --bundle --external:obsidian --outdir=. --target=es2016 --format=cjs"
"dev": "node esbuild.config.mjs",
"build": "node esbuild.config.mjs production"
},
"keywords": [],
"author": "",