-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
68 lines (68 loc) · 1.89 KB
/
vite.config.js
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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import { viteMockServe } from 'vite-plugin-mock'
export default defineConfig(({ command }) => {
return {
plugins: [
vue(),
createSvgIconsPlugin({
// 指定需要缓存的图标文件夹
iconDirs: [path.resolve(process.cwd(), "src/assets/svg")],
// 指定symbolId格式
symbolId: "icon-[dir]-[name]",
}),
// mock配置
viteMockServe({
mockPath: 'mock',
// 只在开发环境中开启
localEnabled: command === 'serve',
// 生产环境中关闭
prodEnabled: false
}),
],
// 开发或生产环境服务的公共基础路径
base: '/',
resolve: {
// 配置路径别名
alias: {
'~': path.resolve(__dirname, './'),
'@': path.resolve(__dirname, 'src')
}
},
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
additionalData: `
@import "${path.resolve(__dirname, 'src/assets/styles/base.less')}";
@import "${path.resolve(__dirname, 'src/assets/styles/mixins.less')}";
`,
},
},
},
// 本地请求代理
server: {
host: '0.0.0.0',
proxy: {
'/api': {
//target: 'http://192.168.102.75:9295',
target: 'http://192.168.102.75:9391',
changeOrigin: true,
},
'/uploads': {
// target: 'http://192.168.102.75:9295',
target: 'http://192.168.102.75:9391',
changeOrigin: true,
},
'/source': {
target: 'http://192.168.102.75:9391',
// target: 'http://192.168.102.58:9291',
changeOrigin: true,
rewrite: path => path.replace(/^\/source/, '')
}
}
}
}
})