2023-06-05 18:45:47 +08:00
|
|
|
/**
|
|
|
|
* {build}
|
|
|
|
* @author yutent<yutent.io@gmail.com>
|
|
|
|
* @date 2021/08/09 11:59:41
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Es from 'esbuild'
|
|
|
|
import fs from 'iofs'
|
|
|
|
|
2023-06-06 15:26:41 +08:00
|
|
|
let args = process.argv.slice(2)
|
|
|
|
let entryPoints = fs.ls('./src', true).filter(it => fs.isfile(it))
|
|
|
|
|
|
|
|
if (args.includes('--watch')) {
|
|
|
|
let res = await Es.context({
|
|
|
|
entryPoints,
|
|
|
|
outdir: 'dist',
|
|
|
|
target: 'es2022',
|
|
|
|
format: 'cjs',
|
|
|
|
// external: ['vscode', 'util'],
|
|
|
|
platform: 'node'
|
|
|
|
// bundle: true
|
|
|
|
})
|
|
|
|
console.log('监听文件变化中...\n')
|
|
|
|
await res.watch()
|
|
|
|
} else {
|
|
|
|
Es.build({
|
|
|
|
entryPoints,
|
|
|
|
outdir: 'dist',
|
|
|
|
target: 'es2022',
|
|
|
|
format: 'cjs',
|
|
|
|
minify: true,
|
|
|
|
// external: ['vscode', 'util'],
|
|
|
|
platform: 'node'
|
|
|
|
// bundle: true
|
|
|
|
})
|
|
|
|
}
|