-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathvite.config.ts
68 lines (64 loc) · 1.45 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import react from '@vitejs/plugin-react-swc';
import externalGlobals from 'rollup-plugin-external-globals';
import { visualizer } from 'rollup-plugin-visualizer';
import { defineConfig, loadEnv } from 'vite';
const env = loadEnv(process.env.NODE_ENV!, process.cwd());
const plugins = [ externalGlobals({
react: 'React',
'react-dom': 'ReactDOM',
antd: 'antd',
'lodash-es': '_',
})]
if (process.env.ANALYZE) {
plugins.push(
visualizer({
open: true, // 直接在浏览器中打开分析报告
gzipSize: true, // 显示gzip后的大小
brotliSize: true, // 显示brotli压缩后的大小
})
)
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react({
jsxImportSource: '@dbfu/react-directive',
}),
],
build: {
rollupOptions: {
external: [
'react',
'react-dom',
'antd',
],
plugins,
}
},
resolve: {
alias: {
'@': '/src/',
},
},
server: {
port: env.VITE_PORT ? +env.VITE_PORT : 5173,
open: true,
proxy: {
'/api': {
target: 'http://localhost:7001',
changeOrigin: true,
},
'/file': {
target: 'http://localhost:9002',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/file/, ''),
},
'/ws': {
target: 'ws://localhost:7001',
changeOrigin: true,
ws: true,
rewrite: (path) => path.replace(/^\/ws/, ''),
},
},
},
})