-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
59 lines (56 loc) · 1.55 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
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import path from "path";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
// vite升级到3或以上版本,打印的地址将不再是localhostl,而是127.0.0.1
// 参考链接:https://juejin.cn/post/7200632181768831013
import dns from "dns";
dns.setDefaultResultOrder("verbatim");
// https://vitejs.dev/config/
export default defineConfig({
server:{
host:'0.0.0.0',//解决vite use--host to expose
port:5173,
open:true
},
resolve: {
alias: {
"~/": `${path.resolve(__dirname, "src")}/`, //获取src文件下的路径
},
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "~/styles/light.scss" as *;`,
},
},
},
plugins: [
vue(),
Components({
resolvers: [
ElementPlusResolver({
importStyle: "sass",
// directives: true,
// version: "2.1.5",
}),
],
}),
AutoImport({
resolvers: [ElementPlusResolver()],
}),
Components({
resolvers: [ElementPlusResolver()],
}),
//去除旧的svg规则,然后添加新的svg规则
createSvgIconsPlugin({
// 指定需要缓存的图标文件夹
iconDirs: [path.resolve(process.cwd(), "src/assets/icons")],
// 指定symbolId格式
symbolId: "icon-[name]",
}),
],
});