-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathvite.config.ts
36 lines (35 loc) · 960 Bytes
/
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
import path from 'node:path'
import process from 'node:process'
import { defineConfig } from 'vite'
import { mockDevServerPlugin } from 'vite-plugin-mock-dev-server'
export default defineConfig(({ mode }) => ({
plugins: [
mockDevServerPlugin({
prefix: '^/api-dev/',
wsPrefix: ['/socket.io'],
log: 'debug',
formidableOptions: {
// 配置上传资源存放目录
uploadDir: path.join(process.cwd(), '/uploads'),
// 可修改上传资源名称
filename: (name, ext, part) => {
return part.originalFilename!
},
},
build: true,
}),
],
// define 注入的变量, 在 mock文件中也可以使用
define: {
__IS_DEVELOPMENT__: JSON.stringify(mode === 'development'),
},
server: {
cors: false,
// 在 proxy 中配置的 代理前缀, mock-dev-server 才会拦截并mock
proxy: {
'^/api': {
target: '',
},
},
},
}))