-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
100 lines (98 loc) · 2.63 KB
/
vite.config.ts
File metadata and controls
100 lines (98 loc) · 2.63 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
93
94
95
96
97
98
99
100
/*
* @Author: yjl
* @Date: 2024-04-18 15:32:24
* @LastEditors: yjl
* @LastEditTime: 2024-07-19 16:51:48
* @Description: 描述
*/
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
import { presetTypography, presetUno } from "unocss";
import UnoCSS from "unocss/vite";
import { viteMockServe } from "vite-plugin-mock";
import { mars3dPlugin } from "vite-plugin-mars3d";
import { visualizer } from "rollup-plugin-visualizer";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
UnoCSS({
presets: [presetUno(), presetTypography()],
}),
viteMockServe({
ignore: /^_/,
mockPath: "mock",
watchFiles: true,
localEnabled: false,
prodEnabled: true,
injectCode: `
import { setupProdMockServer } from '../mock/_createProductionServer';
setupProdMockServer();
`,
}),
visualizer({
open: true, // 注意这里要设置为true,否则无效,如果存在本地服务端口,将在打包后自动展示
gzipSize: true,
brotliSize: true,
}),
mars3dPlugin(),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
build: {
cssTarget: "chrome80",
rollupOptions: {
output: {
chunkFileNames: "static/js/[name]-[hash].js",
entryFileNames: "static/js/[name]-[hash].js",
assetFileNames: "static/[ext]/[name]-[hash].[ext]",
manualChunks: {
vendor: ["react", "react-dom"],
antd: ["antd", "@ant-design/icons"],
},
},
},
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
},
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
server: {
port: 7777,
host: "0.0.0.0",
proxy: {
"/api": {
target: "https://game.gtimg.cn/images/lol/act/img/tft/", // 目标服务器地址
changeOrigin: true, // 改变源到目标服务器
ws: true,
rewrite: (path) => path.replace(new RegExp(`^/api`), ""),
// 其他可选配置...
},
"/base": {
target: "http://124.71.145.91:7001", // 目标服务器地址
changeOrigin: true, // 改变源到目标服务器
ws: true,
rewrite: (path) => path.replace(new RegExp(`^/base`), ""),
},
"/mars3d": {
target: "https://data.mars3d.cn", // 目标服务器地址
changeOrigin: true, // 改变源到目标服务器
ws: true,
rewrite: (path) => path.replace(new RegExp(`^/mars3d`), ""),
},
},
},
});