-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
50 lines (50 loc) · 1.43 KB
/
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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import { ElectronDevPlugin } from './plugins/vite-plugin-electron-dev'
import { ViteLessGlobalVars } from './plugins/vite-less-global-vars'
import { ViteImgToBase64 } from './plugins/vite-img-to-base64'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
build: {
outDir: path.join(__dirname, './app/render-dist'),
},
envDir: path.join(__dirname, './render'),
root: path.join(__dirname, './render'),
base: mode === 'production' ? './' : '/',
server: {
port: 8889,
},
define: {
'import.meta.env.PORT': JSON.stringify(process.env.PORT),
},
plugins: [
react(),
ViteLessGlobalVars({ globalPath: path.resolve(process.cwd(), 'render/src/styles/normal.less') }),
ElectronDevPlugin(),
createSvgIconsPlugin({
iconDirs: [path.resolve(process.cwd(), 'render/src/assets/svg')], //svg地址
symbolId: 'icon-[dir]-[name]',
}),
ViteImgToBase64(),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './render/src'),
'@main': path.resolve(__dirname, './main'),
},
},
optimizeDeps: {
exclude: ['sharp'],
},
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
additionalData: '@root-entry-name: default;',
math: 'always',
},
},
},
}))