-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
92 lines (91 loc) · 2.69 KB
/
vite.config.ts
File metadata and controls
92 lines (91 loc) · 2.69 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* @Author: MuYuCat
* @Date: 2022-04-19 11:58:49
* @LastEditors: MuYuCat
* @LastEditTime: 2022-04-25 13:28:20
* @Description: file content
*/
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
// 如果编辑器提示 path 模块找不到,则可以安装一下 @types/node -> npm i @types/node -D
// 按需使用Element-Plus
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import * as pathBegin from 'path';
export default defineConfig({
plugins: [
vue(),
// 按需使用Element-Plus
AutoImport({
resolvers: [ElementPlusResolver()]
}),
Components({
resolvers: [ElementPlusResolver()]
})
],
resolve: {
alias: {
'@': pathBegin.resolve(__dirname, './src') // 设置 `@` 指向 `src` 目录
}
},
publicDir: 'public',
base: '/', // 打包路径
server: {
proxy: {
'/map': {
target: 'https://api.map.baidu.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/map/, '')
},
'/gaoDeMap': {
target: 'https://restapi.amap.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/gaoDeMap/, '')
},
'/soHuApi': {
target: 'https://pv.sohu.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/soHuApi/, '')
},
'/ipify': {
target: 'https://api.ipify.org',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/ipify/, '')
},
'/weather': {
target: 'https://geoapi.qweather.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/weather/, '')
},
'/devWeather': {
target: 'https://devapi.qweather.com/',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/devWeather/, '')
},
'/poetry': {
target: 'https://v2.jinrishici.com/',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/poetry/, '')
},
'/hitokoto': {
target: 'https://v1.hitokoto.cn/',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/hitokoto/, '')
},
'/blog': {
target: 'http://127.0.0.1:7001/',
changeOrigin: false,
rewrite: (path) => path.replace(/^\/blog/, '')
}
// '/baotaInfo': {
// target: 'http://muyucat.com:8888/',
// changeOrigin: false,
// rewrite: (path) => path.replace(/^\/baotaInfo/, '')
// }
},
port: 8080, // 设置服务启动端口号
open: true, // 设置服务启动时是否自动打开浏览器
cors: true // 允许跨域
}
});