generated from typora-community-plugin/typora-plugin-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
34 lines (28 loc) · 798 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
import * as child_process from 'node:child_process'
import * as fs from 'node:fs/promises'
import * as esbuild from 'esbuild'
import typoraPlugin, { installDevPlugin, closeTypora } from 'esbuild-plugin-typora'
import { sassPlugin } from 'esbuild-sass-plugin'
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')
}