forked from ltxhhz/LL-plugin-list-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
electron.vite.config.ts
81 lines (75 loc) · 1.87 KB
/
electron.vite.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
import { defineConfig } from 'electron-vite'
import { defineConfig as defineViteConfig } from 'vite'
import { resolve } from 'path'
import viteChecker from 'vite-plugin-checker'
import viteCp from 'vite-plugin-cp'
import viteZipPack from 'unplugin-zip-pack/vite'
import PluginManifest from './manifest.json'
const SRC_DIR = resolve(__dirname, './src')
const OUTPUT_DIR = resolve(__dirname, './dist')
const BaseConfig = defineViteConfig({
root: __dirname,
resolve: {
alias: {
'@': SRC_DIR
}
}
})
const ConfigBuilder = (type: 'main' | 'preload') =>
defineViteConfig({
...BaseConfig,
plugins: [
viteChecker({
typescript: true,
eslint: {
lintCommand: 'eslint --fix "src/**/*.{ts,js}"'
}
})
],
build: {
minify: true,
outDir: resolve(OUTPUT_DIR, `./${type}`),
lib: {
entry: resolve(SRC_DIR, `./${type}/index.ts`),
formats: ['cjs'],
fileName: () => 'index.js'
}
}
})
export default defineConfig({
main: ConfigBuilder('main'),
preload: ConfigBuilder('preload'),
renderer: defineViteConfig({
...BaseConfig,
plugins: [
viteChecker({
typescript: true,
eslint: {
lintCommand: 'eslint --fix "src/**/*.{ts,js}"'
}
}),
viteCp({
targets: [
{ src: './manifest.json', dest: 'dist' },
{ src: './src/assets', dest: 'dist/assets' }
]
}),
viteZipPack({
in: OUTPUT_DIR,
out: resolve(__dirname, `./${PluginManifest.slug}.zip`)
})
],
build: {
minify: false,
outDir: resolve(OUTPUT_DIR, './renderer'),
lib: {
entry: resolve(SRC_DIR, './renderer/index.ts'),
formats: ['es'],
fileName: () => 'index.js'
},
rollupOptions: {
input: resolve(SRC_DIR, './renderer/index.ts')
}
}
})
})