-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.mjs
47 lines (41 loc) · 909 Bytes
/
build.mjs
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
40
41
42
43
44
45
46
47
import * as dotenv from 'dotenv'
import esbuild from 'esbuild'
import fs from 'fs-extra'
import process from 'node:process'
dotenv.config()
const outdir = 'dist'
async function deleteOldDir() {
await fs.remove(outdir)
}
async function runEsbuild() {
await esbuild.build({
entryPoints: [
'src/index.ts',
],
bundle: true,
outdir: outdir,
treeShaking: true,
minify: true,
drop: ['console', 'debugger'],
legalComments: 'none',
define: {
'process.env.NODE_ENV': '"production"',
'process.env.AXIOM_TOKEN': JSON.stringify(process.env.AXIOM_TOKEN || 'UNDEFINED'),
},
jsxFactory: 'h',
jsxFragment: 'Fragment',
jsx: 'automatic',
loader: {
'.png': 'dataurl',
'.svg': 'dataurl',
},
plugins: [
]
})
}
async function build() {
await deleteOldDir()
await runEsbuild()
console.log('Build success.')
}
build()