-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.ts
39 lines (28 loc) · 1.06 KB
/
build.ts
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
import { resolve, dirname } from 'path'
import { copy, copyFile, outputFile, readJSON, writeJSON } from 'fs-extra'
import ncc from '@vercel/ncc'
async function main() {
const rootDir = __dirname
const input = resolve(rootDir, 'src', 'jimp.ts')
const output = resolve(rootDir, 'dist', 'jimp.cjs')
const pkg = resolve(rootDir, 'package.json')
const opts = {
cache: false,
minify: true,
sourceMapRegister: false
}
// @ts-ignore
let { code } = await ncc(input, opts)
code = code.replace(/new Buffer/g, 'new JIMPBUffer')
await outputFile(output, code)
const jimpDir = dirname(require.resolve('jimp/package.json'))
// const { version } = await readJSON(resolve(jimpDir, 'package.json'))
// await writeJSON(pkg, { ...await readJSON(pkg), version }, { spaces: 2 })
await copy(resolve(jimpDir, 'fonts'), resolve(rootDir, 'fonts'))
await copyFile(resolve(jimpDir, 'types/ts3.1/index.d.ts'), resolve(rootDir, 'dist/jimp.d.ts'))
// console.log('jimp-compact@' + version)
}
main().catch(error => {
console.error(error)
process.exit(1)
})