forked from baizeteam/baize-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
electron.vite.config.ts
73 lines (71 loc) · 2.15 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
import { resolve } from "path"
import { defineConfig, externalizeDepsPlugin } from "electron-vite"
import react from "@vitejs/plugin-react"
import reactCssModule from "vite-plugin-react-css-modules"
import genericNames from "generic-names"
import autoprefixer from "autoprefixer"
const generateScopedName = genericNames("[name]__[local]__[hash:base64:4]")
export default defineConfig({
main: {
plugins: [externalizeDepsPlugin()],
},
preload: {
plugins: [externalizeDepsPlugin()],
},
renderer: {
resolve: {
alias: {
"@renderer": resolve("src/renderer"),
"@siteMain": resolve("src/renderer/siteMain/src"),
"@siteAssistOpaque": resolve("src/renderer/siteAssistOpaque/src"),
"@siteAssistTransprent": resolve("src/renderer/siteAssistTransprent/src"),
"@siteElectronLoading": resolve("src/renderer/siteElectronLoading/src"),
},
},
plugins: [
reactCssModule({
generateScopedName,
filetypes: {
".less": {
syntax: "postcss-less",
},
},
}),
react(),
],
css: {
modules: {
generateScopedName: generateScopedName,
},
postcss: {
plugins: [autoprefixer],
},
preprocessorOptions: {
less: {
additionalData: `@import '@renderer/assets/styles/theme.less';`,
javascriptEnabled: true,
},
},
},
build: {
minify: "terser",
cssMinify: "esbuild",
rollupOptions: {
input: {
siteMain: resolve(__dirname, "src/renderer/siteMain/index.html"),
siteAssistTransprent: resolve(__dirname, "src/renderer/siteAssistTransprent/index.html"),
siteAssistOpaque: resolve(__dirname, "src/renderer/siteAssistOpaque/index.html"),
siteElectronLoading: resolve(__dirname, "src/renderer/siteElectronLoading/index.html"),
},
output: {
manualChunks: {
reactBase: ["react", "react-dom"],
reactEcology: ["react-router-dom", "mobx", "mobx-react"],
tools: ["ahooks", "lodash", "nanoid"],
// antd: ["antd"],
},
},
},
},
},
})