-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
70 lines (68 loc) · 1.49 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import fs from 'fs'
import { resolve } from 'path'
import { defineConfig } from 'vite'
import reactRefresh from '@vitejs/plugin-react-refresh'
import { viteMockServe } from 'vite-plugin-mock'
import styleImport from 'vite-plugin-style-import'
import lessToJS from 'less-vars-to-js'
const customTheme = lessToJS(fs.readFileSync(resolve(__dirname, './src/config/theme.less'), 'utf8'))
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@src': resolve(__dirname, './src'),
'@assets': resolve(__dirname, './src/assets'),
'@components': resolve(__dirname, './src/components'),
'@pages': resolve(__dirname, './src/pages'),
'@uitls': resolve(__dirname, './src/uitls'),
'@styles': resolve(__dirname, './src/styles'),
'@config': resolve(__dirname, './src/config')
}
},
plugins: [
reactRefresh(),
// mock
viteMockServe({
mockPath: 'mock',
localEnabled: true
}),
// antd 按需引入
styleImport({
libs: [
{
libraryName: 'antd',
resolveStyle: (name) => `antd/es/${name}/style`
}
]
})
],
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
modifyVars: customTheme
}
},
modules: {}
},
build: {
target: 'es2015',
minify: 'terser',
cssCodeSplit: true,
rollupOptions: {
plugins: []
}
},
server: {
proxy: {
'/api': {
target: 'http://192.168.3.75:30383',
changeOrigin: true,
rewrite: (path: string) => path.replace(/^\/api/, '')
}
},
hmr: {
overlay: false
}
}
})