-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.config.ts
54 lines (51 loc) · 1.25 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
import { exec } from 'node:child_process'
import { promisify } from 'node:util'
import { env } from 'node:process'
import { defineBuildConfig } from 'unbuild'
import builtins from 'builtin-modules'
const execAsync = promisify(exec)
export default defineBuildConfig({
outDir: './dist',
sourcemap: true,
declaration: false,
externals: [
// Obsidian
'obsidian',
'electron',
'@codemirror/autocomplete',
'@codemirror/collab',
'@codemirror/commands',
'@codemirror/language',
'@codemirror/lint',
'@codemirror/search',
'@codemirror/state',
'@codemirror/view',
'@lezer/common',
'@lezer/highlight',
'@lezer/lr',
// Builtins
...builtins,
],
rollup: {
esbuild: {
format: 'cjs',
},
output: {
dir: './dist',
format: 'cjs',
sourcemap: env.NODE_ENV === 'development' ? 'inline' : false,
entryFileNames: 'main.js',
},
// required for unocss, ofetch, etc.
// otherwise unbuild will detect them as external
// dependencies that are inline implicitly external
// by esbuild
inlineDependencies: true,
},
hooks: {
'build:done': async () => {
await execAsync('rm -rf ./main.js')
await execAsync('cp ./dist/main.js ./main.js')
},
},
})