-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.config.ts
60 lines (57 loc) · 1.59 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
55
56
57
58
59
60
import { copyFile, rm } from 'node:fs/promises'
import { join } from 'node:path'
import { cwd } from 'node:process'
import builtins from 'builtin-modules'
import { defineBuildConfig } from 'unbuild'
import { generateObsidianPluginManifest } from './scripts/manifest'
import { toErrorable } from './scripts/utils'
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: 'inline',
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:before': async () => {
await toErrorable(async () => await rm(join(cwd(), 'main.js')))
await toErrorable(async () => await rm(join(cwd(), 'manifest.json')))
},
'build:done': async () => {
await generateObsidianPluginManifest()
await copyFile(join(cwd(), 'dist', 'main.js'), join(cwd(), 'main.js'))
await copyFile(join(cwd(), 'dist', 'manifest.json'), join(cwd(), 'manifest.json'))
},
},
})