-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.mts
98 lines (95 loc) · 2.95 KB
/
vite.config.mts
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
import { ConfigEnv, UserConfigExport } from "vite";
import vue from "@vitejs/plugin-vue";
import { viteMockServe } from "vite-plugin-mock";
// import { vitePluginSvg } from "@webxrd/vite-plugin-svg";
import { resolve } from "path";
const pathResolve = (dir: string): any => {
return resolve(__dirname, ".", dir);
};
const alias: Record<string, string> = {
"@": pathResolve("src"),
};
/**
* @description-en vite document address
* @description-cn vite官网
* https://vitejs.cn/config/ */
export default ({ command }: ConfigEnv): UserConfigExport => {
const prodMock = true;
return {
base: "./",
resolve: {
alias,
},
server: {
port: 3001,
host: "0.0.0.0",
open: true,
proxy: {
// 代理配置
// "/api": {
// target: "http://localhost:3000",
// changeOrigin: true,
// },
"/geo": {
target: "https://geo.datav.aliyun.com",
changeOrigin: true,
rewrite(path) {
return path.replace("/geo", "");
},
},
},
},
build: {
rollupOptions: {
output: {
manualChunks: {
echarts: ["echarts"],
},
},
},
},
plugins: [
vue(),
// viteMockServe({
// mockPath: 'mock',
// localEnabled: command === 'serve',
// prodEnabled: command !== 'serve' && prodMock,
// watchFiles: true,
// injectCode: `
// import { setupProdMockServer } from '../mockProdServer';
// setupProdMockServer();
// `,
// logger: true,
// }),
// vitePluginSvg({
// // 必要的。必须是绝对路径组成的数组。
// iconDirs: [resolve(__dirname, "src/assets/svg")],
// // 必要的。入口script
// main: resolve(__dirname, "src/main.js"),
// symbolIdFormat: "icon-[name]",
// }),
],
css: {
postcss: {
plugins: [
{
postcssPlugin: "internal:charset-removal",
AtRule: {
charset: (atRule) => {
if (atRule.name === "charset") {
atRule.remove();
}
},
},
},
],
},
preprocessorOptions: {
scss: {
// api:'modern-compiler'
api: 'modern-compiler'
}
}
},
};
};