-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ts
More file actions
39 lines (33 loc) · 800 Bytes
/
Copy pathbuild.ts
File metadata and controls
39 lines (33 loc) · 800 Bytes
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
37
38
39
#!/usr/bin/env node
import arg from 'arg'
import { build } from 'tsup'
import { getValuesObj } from './src/pkgJson.js'
const spec = {
'-q': Boolean,
'--dev': Boolean,
'--out': String,
}
async function buildProject() {
const args = arg(spec)
const isQuiet = args['-q'] ?? false
const isDev = args['--dev'] ?? false
const outDir = args['--out'] ?? 'dist'
await build({
entry: {
'cli': 'src/cli.ts',
'index': 'src/index.ts'
},
format: ['esm'],
dts: true,
sourcemap: true,
clean: true,
minify: !isDev,
outDir: outDir,
silent: isQuiet,
onSuccess: `echo 'DONE: tsup: built to "${outDir}/".'`,
define: {
'__BUNDLED_PKGJSON_VALUES__': JSON.stringify(await getValuesObj()),
},
})
}
buildProject().catch(console.error)