-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.ts
80 lines (77 loc) · 1.93 KB
/
rollup.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { createRequire } from 'node:module'
import { defineConfig } from 'rollup'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import ts from '@rollup/plugin-typescript'
import dts from 'rollup-plugin-dts'
import rm from 'rollup-plugin-rm'
const require = createRequire(import.meta.url)
const pkg = require('./package.json')
const external = [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {})
]
export default defineConfig([
{
input: ['src/main.ts', 'src/preload.ts', 'src/renderer.ts'],
output: [
{
entryFileNames: '[name].cjs',
chunkFileNames: 'chunks/lib-[hash].cjs',
format: 'cjs',
dir: 'dist'
},
{
entryFileNames: '[name].mjs',
chunkFileNames: 'chunks/lib-[hash].mjs',
format: 'es',
dir: 'dist'
}
],
external,
plugins: [
rm('dist', 'buildStart'),
resolve({ exportConditions: ['node', 'default', 'module', 'import'] }),
commonjs(),
ts({
compilerOptions: {
rootDir: 'src',
declaration: true,
outDir: 'dist/types'
}
})
]
},
{
input: ['src/global.ts'],
output: [
{
entryFileNames: 'electron-conf-preload.cjs',
format: 'cjs',
dir: 'dist'
},
{
entryFileNames: 'electron-conf-preload.mjs',
format: 'es',
dir: 'dist'
}
],
external,
plugins: [resolve(), commonjs(), ts()]
},
{
input: ['dist/types/main.d.ts'],
output: [{ file: './dist/main.d.ts', format: 'es' }],
plugins: [dts()]
},
{
input: ['dist/types/preload.d.ts'],
output: [{ file: './dist/preload.d.ts', format: 'es' }],
plugins: [dts()]
},
{
input: ['dist/types/renderer.d.ts'],
output: [{ file: './dist/renderer.d.ts', format: 'es' }],
plugins: [dts(), rm('dist/types', 'buildEnd')]
}
])