-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdev.js
36 lines (31 loc) · 856 Bytes
/
dev.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
36
const args = require('minimist')(process.argv.slice(2))
const { resolve } = require('path')
const { build } = require('esbuild')
const target = args._[0] || 'reactivity'
const format = args.f || 'global'
const pkg = require(resolve(__dirname, `../packages/${target}/package.json`))
const outputFormat = format.startsWith('global')
? 'iife'
: format === 'cjs'
? 'cjs'
: 'esm'
const outfile = resolve(
__dirname,
`../packages/${target}/dist/${target}-${format}.js`
)
build({
entryPoints: [resolve(__dirname, `../packages/${target}/src/index.ts`)],
outfile,
bundle: true,
sourcemap: true,
format: outputFormat,
globalName: pkg.buildOptions?.name,
platform: format === 'cjs' ? 'node' : 'browser',
watch: {
onRebuild(err) {
if (!err) console.log('rebuild~~~')
}
}
}).then(() => {
console.log('watching~~~')
})