项目微调
引入按需自动导入插件,避免开发人员显示导入vue的函数
This commit is contained in:
@@ -2,6 +2,7 @@ import { defineConfig, loadEnv, ConfigEnv, UserConfig } from "vite";
|
||||
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import path from "path";
|
||||
// 处理env环境参数读取
|
||||
import { wrapperEnv } from "./build/getEnv";
|
||||
import { createProxy } from "./build/proxy";
|
||||
// 导入
|
||||
@@ -23,18 +24,39 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||
symbolId: "icon-[dir]-[name]",
|
||||
}),
|
||||
AutoImport({
|
||||
// 自动导入 Vue 相关函数,如:ref, reactive, toRef 等
|
||||
imports: ["vue", "@vueuse/core", "pinia", "vue-router", "vue-i18n"],
|
||||
resolvers: [
|
||||
// 自动导入 Element Plus 相关函数,如:ElMessage, ElMessageBox... (带样式)
|
||||
ElementPlusResolver({
|
||||
importStyle: "sass",
|
||||
}),
|
||||
],
|
||||
eslintrc: {
|
||||
// 是否自动生成 eslint 规则,建议生成之后设置 false
|
||||
enabled: false,
|
||||
// 指定自动导入函数 eslint 规则的文件
|
||||
filepath: "./.eslintrc-auto-import.json",
|
||||
globalsPropValue: true,
|
||||
},
|
||||
// 是否在 vue 模板中自动导入
|
||||
vueTemplate: true,
|
||||
// 指定自动导入函数TS类型声明文件路径 (false:关闭自动生成)
|
||||
dts: false,
|
||||
// dts: "src/types/auto-imports.d.ts",
|
||||
}),
|
||||
Components({
|
||||
resolvers: [
|
||||
// 自动导入 Element Plus 组件
|
||||
ElementPlusResolver({
|
||||
importStyle: "sass",
|
||||
}),
|
||||
],
|
||||
// 指定自定义组件位置(默认:src/components)
|
||||
dirs: ["src/components", "src/**/components"],
|
||||
// 指定自动导入组件TS类型声明文件路径 (false:关闭自动生成)
|
||||
dts: false,
|
||||
// dts: "src/types/components.d.ts",
|
||||
}),
|
||||
// 增加此行代码
|
||||
vueJsx(),
|
||||
|
||||
Reference in New Issue
Block a user