-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
72 lines (71 loc) · 2.42 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
69
70
71
72
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx"; // 支持对jsx语法的支持
import viteSvgIcons from "vite-plugin-svg-icons"; // 对svg图片进行支持
import Components from "unplugin-vue-components/vite"; // 按需自动引入组件
import viteCompression from "vite-plugin-compression"; // 压缩的插件
import WindiCSS from "vite-plugin-windicss";
import { ArcoResolver } from "unplugin-vue-components/resolvers";
import removeConsole from "vite-plugin-remove-console";
import { resolve } from "path";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
vueJsx(),
viteSvgIcons({
// 配置路劲在你的src里的svg存放文件
iconDirs: [resolve(process.cwd(), "static/icons")],
symbolId: "icon-[dir]-[name]",
}),
Components({
dirs: ["src/packages/components"],
resolvers: [ArcoResolver()],
}),
viteCompression(),
WindiCSS(),
removeConsole(), // 去除线上的console.log
],
resolve: {
alias: {
"@": resolve(__dirname, "src"), // 设置 `@` 指向 `src` 目录
"@packages": resolve(__dirname, "src/packages"), // packages
"@common": resolve(__dirname, "src/common"), // packages
"@views": resolve(__dirname, "src/views"), // packages
"@utils": resolve(__dirname, "src/utils"), // plugins
"@plugins": resolve(__dirname, "src/plugins"), // plugins
"@router": resolve(__dirname, "src/router"), // plugins
"@config": resolve(__dirname, "src/config"), // 配置文件
"@store": resolve(__dirname, "src/store"), // 持久化
"@service": resolve(__dirname, "src/service"),
"@types": resolve(__dirname, "types"),
},
},
base: "./", // 设置打包路径
server: {
port: 4000, // 设置服务启动端口号
open: true, // 设置服务启动时是否自动打开浏览器
cors: true, // 允许跨域
host: "0.0.0.0", // ← 新增内容 ←
// 设置代理,根据我们项目实际情况配置
proxy: {
"/api": {
target: "http://10.1.8.31:5000",
changeOrigin: true,
secure: false,
// rewrite: (path) => path.replace('/api/', '/')
},
},
},
esbuild: {
jsxFactory: "h",
jsxFragment: "Fragment",
},
// rollupOptions: {
// output: {
// manualChunks: {
// "lodash-es": ["lodash-es"],
// },
// },
// },
});