-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.config.ts
41 lines (39 loc) · 935 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
40
41
import fs from 'node:fs'
import { defineBuildConfig } from 'unbuild'
import { log, r } from './utils/utils'
export default defineBuildConfig([{
hooks: {
'build:before': async () => {
const proc = Bun.spawn(['bun', 'pre'])
const text = await new Response(proc.stdout).text()
log(text)
},
},
entries: [
'src/background.ts',
{ input: 'extension/' },
],
rollup: {
inlineDependencies: true,
},
}, {
entries: [
'src/content.ts',
],
replace: {
'import.meta.vitest': 'undefined',
},
}, {
hooks: {
'build:done': () => {
fs.readdirSync(r('dist')).forEach((file) => {
if (file.endsWith('.mjs'))
fs.renameSync(r('dist', file), r('dist', file.replace('.mjs', '.js')))
})
fs.copyFileSync(r('node_modules/webextension-polyfill/dist/browser-polyfill.js'), r('dist/browser-polyfill.js'))
},
},
entries: [
'src/popup.ts',
],
}])