-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
92 lines (83 loc) · 2.8 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { UserConfig, ConfigEnv, loadEnv, defineConfig } from "vite"
import veauryVitePlugins from "veaury/vite/index.js"
import Icons from "unplugin-icons/vite"
import AutoImport from "unplugin-auto-import/vite"
import Components from "unplugin-vue-components/vite"
import IconsResolver from "unplugin-icons/resolver"
import { ElementPlusResolver } from "unplugin-vue-components/resolvers"
import UnoCSS from "unocss/vite"
import path from "path"
const pathSrc = path.resolve(__dirname, "src")
export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
const env = loadEnv(mode, process.cwd())
console.log("env:", env)
return {
resolve: {
alias: {
"@": pathSrc
}
},
css: {
preprocessorOptions: {
less: {
additionalData: '@import "@/styles/variables.module.less";',
javascriptEnabled: true
}
}
},
plugins: [
veauryVitePlugins({
type: "vue"
// Configuration of @vitejs/plugin-vue
// vueOptions: {...},
// Configuration of @vitejs/plugin-react
// reactOptions: {...},
// Configuration of @vitejs/plugin-vue-jsx
// vueJsxOptions: {...}
}),
UnoCSS(),
AutoImport({
// 自动导入 Vue 相关函数,如:ref, reactive, toRef 等
imports: ["vue"],
eslintrc: {
enabled: false, // Default `false`
filepath: "./.eslintrc-auto-import.json", // Default `./.eslintrc-auto-import.json`
globalsPropValue: true // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
},
resolvers: [
// 自动导入 Element Plus 相关函数,如:ElMessage, ElMessageBox... (带样式)
ElementPlusResolver(),
// 自动导入图标组件
IconsResolver({})
],
vueTemplate: true, // 是否在 vue 模板中自动导入
dts: path.resolve(pathSrc, "typings", "auto-imports.d.ts") // 自动导入组件类型声明文件位置,默认根目录; false 关闭自动生成
}),
Components({
resolvers: [
// 自动注册图标组件
IconsResolver({
prefix: "icon",
enabledCollections: ["ep"] //@iconify-json/ep 是 Element Plus 的图标库
}),
// Auto register Element Plus components
// 自动导入 Element Plus 组件
ElementPlusResolver()
],
dts: path.resolve(pathSrc, "typings", "components.d.ts")
}),
Icons({
// 自动安装图标库
autoInstall: true
})
], // end of plugins
// refer to https://dev.to/ysmnikhil/how-to-build-with-react-or-vue-with-vite-and-docker-1a3l
server: {
host: true,
port: 8225,
watch: {
usePolling: true
}
}
}
})