forked from niivue/niivue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle.js
More file actions
26 lines (23 loc) · 666 Bytes
/
bundle.js
File metadata and controls
26 lines (23 loc) · 666 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
import { readFile, writeFile } from 'fs/promises'
import { build } from 'tsup'
// inline top-level async/await
;(async () => {
// build bundle with tsup
await build({
entry: ['src/niivue/index.ts'],
outDir: 'dist_intermediate',
target: 'es2020',
splitting: false,
format: 'esm',
sourcemap: false,
clean: true,
loader: {
'.jpg': 'dataurl',
'.png': 'dataurl'
},
minify: 'terser'
})
// load output and export it again as a string
const content = await readFile('./dist_intermediate/index.js', 'utf-8')
await writeFile('./build/index.min.js', `export const esm = "${encodeURIComponent(content)}"`)
})()