generated from typora-community-plugin/typora-plugin-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
35 lines (31 loc) · 815 Bytes
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import * as esbuild from 'esbuild';
import typoraPlugin, {
closeTypora,
installDevPlugin,
} from 'esbuild-plugin-typora';
import { sassPlugin } from 'esbuild-sass-plugin';
import * as child_process from 'node:child_process';
import * as fs from 'node:fs/promises';
const args = process.argv.slice(2);
const IS_PROD = args.includes('--prod');
const IS_DEV = !IS_PROD;
await fs.rm('./dist', { recursive: true, force: true });
await esbuild.build({
entryPoints: ['src/main.ts'],
outdir: 'dist',
format: 'esm',
bundle: true,
minify: IS_PROD,
sourcemap: IS_DEV,
plugins: [
typoraPlugin({
mode: IS_PROD ? 'production' : 'development',
}),
sassPlugin(),
],
});
if (IS_DEV) {
await installDevPlugin();
await closeTypora();
child_process.exec('typora ./test/vault/doc.md');
}