forked from ishareme/vue3-front-common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
45 lines (44 loc) · 1.37 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
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
createSvgIconsPlugin({
// 指定需要缓存的图标文件夹
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
// 指定symbolId格式
symbolId: 'icon-[name]',
}),
],
resolve: {
// 软连接
alias: {
'@': path.join(__dirname, 'src'),
},
// 忽略后缀名的配置选项, 添加 .vue 选项时要记得原本默认忽略的选项也要手动写入
extensions: ['.js', '.ts', '.jsx', '.tsx', '.json', '.vue', '.mjs'],
},
server: {
// 代理配置
proxy: {
// 指定代理的请求
// pexel
'/api': {
target: 'https://api.pexels.com/v1/',
//跨域
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
// unsplash
'/upapi': {
target: 'https://api.unsplash.com/',
//跨域
changeOrigin: true,
rewrite: (path) => path.replace(/^\/upapi/, ''),
},
},
},
});