-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ts
45 lines (29 loc) · 1.04 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
40
41
42
43
44
45
import esbuild from 'esbuild'
import { deleteSync } from 'del'
import fs from 'node:fs/promises'
import path from 'node:path'
import vite from 'vite'
enum BuildTarget {
Firefox = 'firefox',
Chrome = 'chrome'
}
async function main() {
const target: BuildTarget | string = process.argv[2]
if (target !== BuildTarget.Firefox && target !== BuildTarget.Chrome) {
console.error('only allowed firefox and chrome as argument')
process.exit(1)
}
console.log(`Building for ${target}`)
const distPath = path.join('dist', target)
deleteSync(distPath)
await Promise.all([
vite.build({ configFile: 'vite.config.ts', clearScreen: false }),
vite.build({ configFile: 'vite.devtools.config.ts', clearScreen: false })
])
await Promise.all([
fs.copyFile(`manifest.${target}.json`, path.join(distPath, 'manifest.json')),
fs.cp('icons', path.join(distPath, 'icons'), { recursive: true })
])
console.log(`Build for ${target} finished`)
}
main()