-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
51 lines (49 loc) · 1.42 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
import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import eslintPlugin from 'vite-plugin-eslint';
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import { createHtmlPlugin } from 'vite-plugin-html';
import { viteMockServe } from 'vite-plugin-mock';
import path from 'path';
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
server: {
port: 8080,
// port: 80,
host: true,
proxy: {
'/api': {
target: 'https://consult-api.itheima.net',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
}
},
},
plugins: [
vue(),
eslintPlugin(),
createHtmlPlugin(),
viteMockServe({
mockPath: './src/mock',
enable: true
}),
// 自动导入组件
Components({
dts: 'src/components.d.ts', // generate `components.d.ts` global declarations
// vant 样式全局引入了,关闭自动按需引入
resolvers: [VantResolver({ importStyle: false })],
}),
createSvgIconsPlugin({
// 指定图标文件夹,绝对路径(NODE代码)
iconDirs: [path.resolve(process.cwd(), 'src/icons')]
})
],
});