-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.js
45 lines (38 loc) · 1.11 KB
/
build.js
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
/* eslint-disable @typescript-eslint/no-var-requires */
const child_process = require('child_process')
const esbuild = require('esbuild')
const svgrPlugin = require('esbuild-plugin-svgr')
const production = process.env.NODE_ENV === 'production'
const tailwindCSSPlugin = {
name: 'tailwindcss',
setup: (build) => {
build.onEnd(() => {
const { stdout, stderr } = child_process.spawnSync('tailwindcss', [
'--input',
'./static/main.css',
'--output',
'./out/main.css',
'--color',
production ? '--minify' : '',
])
process.stdout.write(stdout)
process.stderr.write(stderr)
})
},
}
const watch = ['y', 'yes', 'true', '1'].includes(
process.env.BUILD_WATCH?.toLowerCase()
)
esbuild
.build({
entryPoints: ['src/background/index.ts', 'src/panel/index.tsx'],
bundle: true,
drop: production ? ['console', 'debugger'] : [],
minify: production,
sourcemap: production ? false : 'inline',
plugins: [tailwindCSSPlugin, svgrPlugin({ icon: true })],
outdir: 'out',
logLevel: 'info',
watch,
})
.catch(() => process.exit(1))