This repository has been archived by the owner on Jul 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrollup.config.ts
84 lines (79 loc) · 1.86 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
81
82
83
84
import { defineConfig } from 'rollup'
import path from 'path'
import replace from '@rollup/plugin-replace'
import esbuild from 'rollup-plugin-esbuild'
import eslint from '@rollup/plugin-eslint'
import json from '@rollup/plugin-json'
import cjs from '@rollup/plugin-commonjs'
import node from '@rollup/plugin-node-resolve'
import alias from '@rollup/plugin-alias'
const main = (dev: boolean) => defineConfig({
input: path.resolve(__dirname, 'src', 'app', 'index.main.ts'),
plugins: [
eslint(),
json(),
alias({
entries: [
{ find: 'uuid', replacement: require.resolve('uuid') }
]
}),
node({
browser: false,
mainFields: ['module', 'main']
}),
cjs(),
esbuild({
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
minify: !dev,
minifyIdentifiers: !dev,
minifyWhitespace: !dev,
minifySyntax: !dev,
sourceMap: dev
}),
!dev
? replace({
values: {
'process.env.NODE_ENV': `"${process.env.NODE_ENV}"`,
'process.env.VITE_URL': 'null'
},
preventAssignment: true
})
: undefined
],
output: {
file: 'dist/main/index.js',
format: 'cjs',
sourcemap: dev
}
})
const preload = (dev: boolean) => defineConfig({
input: path.resolve(__dirname, 'src', 'app', 'index.preload.ts'),
plugins: [
eslint(),
json(),
node({
browser: false
}),
cjs({
}),
alias({
entries: [
{ find: 'uuid', replacement: require.resolve('uuid') }
]
}),
esbuild({
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
minify: !dev,
minifyIdentifiers: !dev,
minifyWhitespace: !dev,
minifySyntax: !dev,
sourceMap: dev
})
],
output: {
file: 'dist/main/preload_main.js',
format: 'cjs',
sourcemap: dev
}
})
export default { main, preload }