chore: 🔨 注释简化

This commit is contained in:
ray
2024-11-01 15:46:25 +08:00
parent 32010211e6
commit 6ea4c6d718

View File

@@ -18,16 +18,14 @@ import {
devDependencies, devDependencies,
} from "./package.json"; } from "./package.json";
// 平台的名称、版本、运行所需的`node`版本、依赖、构建时间的类型提示 // 平台的名称、版本、运行所需的 node 版本、依赖、构建时间的类型提示
const __APP_INFO__ = { const __APP_INFO__ = {
pkg: { name, version, engines, dependencies, devDependencies }, pkg: { name, version, engines, dependencies, devDependencies },
buildTimestamp: Date.now(), buildTimestamp: Date.now(),
}; };
const pathSrc = resolve(__dirname, "src"); const pathSrc = resolve(__dirname, "src");
/** // Vite配置 https://cn.vitejs.dev/config
* Vite配置 @see https://cn.vitejs.dev/config
*/
export default defineConfig(({ mode }: ConfigEnv): UserConfig => { export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
const env = loadEnv(mode, process.cwd()); const env = loadEnv(mode, process.cwd());
return { return {
@@ -37,7 +35,6 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
}, },
}, },
css: { css: {
// CSS 预处理器
preprocessorOptions: { preprocessorOptions: {
// 定义全局 SCSS 变量 // 定义全局 SCSS 变量
scss: { scss: {
@@ -50,17 +47,14 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
}, },
}, },
server: { server: {
// 主机地址
host: "0.0.0.0", host: "0.0.0.0",
// 端口号
port: +env.VITE_APP_PORT, port: +env.VITE_APP_PORT,
// 是否自动在浏览器中打开
open: true, open: true,
proxy: { proxy: {
// 代理前缀为 /dev-api 的请求 // 代理 /dev-api 的请求
[env.VITE_APP_BASE_API]: { [env.VITE_APP_BASE_API]: {
changeOrigin: true, changeOrigin: true,
// 代理目标真实接口地址https://api.youlai.tech // 代理目标地址https://api.youlai.tech
target: env.VITE_APP_API_URL, target: env.VITE_APP_API_URL,
rewrite: (path) => rewrite: (path) =>
path.replace(new RegExp("^" + env.VITE_APP_BASE_API), ""), path.replace(new RegExp("^" + env.VITE_APP_BASE_API), ""),
@@ -69,49 +63,41 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
}, },
plugins: [ plugins: [
vue(), vue(),
// MOCK 服务
env.VITE_MOCK_DEV_SERVER === "true" ? mockDevServerPlugin() : null, env.VITE_MOCK_DEV_SERVER === "true" ? mockDevServerPlugin() : null,
UnoCSS({ UnoCSS({
hmrTopLevelAwait: false, hmrTopLevelAwait: false,
}), }),
/** // 自动导入配置 https://github.com/sxzz/element-plus-best-practices/blob/main/vite.config.ts
* 自动导入配置
*
* @see https://github.com/sxzz/element-plus-best-practices/blob/main/vite.config.ts1
*/
AutoImport({ AutoImport({
// 自动导入 Vue 相关函数ref, reactive, toRef 等 // 导入 Vue 函数ref, reactive, toRef 等
imports: ["vue", "@vueuse/core", "pinia", "vue-router", "vue-i18n"], imports: ["vue", "@vueuse/core", "pinia", "vue-router", "vue-i18n"],
resolvers: [ resolvers: [
// 自动导入 Element Plus 相关函数ElMessage, ElMessageBox... (带样式) // 导入 Element Plus函数ElMessage, ElMessageBox
ElementPlusResolver(), ElementPlusResolver(),
], ],
eslintrc: { eslintrc: {
// 是否自动生成 eslint 规则,建议生成之后设置 false
enabled: false, enabled: false,
// 指定自动导入函数 eslint 规则的文件
filepath: "./.eslintrc-auto-import.json", filepath: "./.eslintrc-auto-import.json",
globalsPropValue: true, globalsPropValue: true,
}, },
// 是否在 vue 模板中自动导入
vueTemplate: true, vueTemplate: true,
// 指定自动导入函数TS类型声明文件路径 (false:关闭自动生成) // 导入函数类型声明文件路径 (false:关闭自动生成)
dts: false, dts: false,
// dts: "src/types/auto-imports.d.ts", // dts: "src/types/auto-imports.d.ts",
}), }),
Components({ Components({
resolvers: [ resolvers: [
// 自动导入 Element Plus 组件 // 导入 Element Plus 组件
ElementPlusResolver(), ElementPlusResolver(),
], ],
// 指定自定义组件位置(默认:src/components) // 指定自定义组件位置(默认:src/components)
dirs: ["src/components", "src/**/components"], dirs: ["src/components", "src/**/components"],
// 指定自动导入组件TS类型声明文件路径 (false:关闭自动生成) // 导入组件类型声明文件路径 (false:关闭自动生成)
dts: false, dts: false,
// dts: "src/types/components.d.ts", // dts: "src/types/components.d.ts",
}), }),
createSvgIconsPlugin({ createSvgIconsPlugin({
// 指定需要缓存图标文件夹 // 缓存图标位置
iconDirs: [resolve(pathSrc, "assets/icons")], iconDirs: [resolve(pathSrc, "assets/icons")],
symbolId: "icon-[dir]-[name]", symbolId: "icon-[dir]-[name]",
}), }),