-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.config.ts
39 lines (34 loc) · 1008 Bytes
/
build.config.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 { minify } from 'minify'
;(async () => {
console.log('\n🛠️ Starting building library... \n')
const bundler = await Bun.build({
minify: true,
target: 'bun',
outdir: './dist',
sourcemap: 'none',
entrypoints: ['./src/index.ts'],
external: ['vite', 'semver', 'picocolors', 'vite-plugin-full-reload']
})
if (!bundler.success) {
console.error('Error: Something went wrong with building library!', bundler.logs)
return
}
const compressHtml = await minify('./index.html', {
html: {
removeComments: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
minifyCSS: true,
minifyJS: true,
minifyURLs: true
}
})
if (typeof compressHtml !== 'string') {
console.error('Error: Something went wrong while minify the HTML file.')
return
}
await Bun.write('./dist/index.html', compressHtml, { createPath: true })
console.log('✅ Library build successfully.')
})()