refactor: ♻️ 项目重构(临时提交)
Former-commit-id: 14e64324f7556c095c38ad289690367cdac0ec56
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
|
||||
import { UserConfig, ConfigEnv, loadEnv, defineConfig } from "vite";
|
||||
|
||||
import AutoImport from "unplugin-auto-import/vite";
|
||||
@@ -12,14 +11,13 @@ import IconsResolver from "unplugin-icons/resolver";
|
||||
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
|
||||
|
||||
import { viteMockServe } from "vite-plugin-mock";
|
||||
|
||||
import vueJsx from "@vitejs/plugin-vue-jsx";
|
||||
|
||||
import UnoCSS from "unocss/vite";
|
||||
import path from "path";
|
||||
import { resolve } from "path";
|
||||
|
||||
const pathSrc = path.resolve(__dirname, "src");
|
||||
// 参考Vite官方: https://cn.vitejs.dev/config
|
||||
const pathSrc = resolve(__dirname, "src");
|
||||
// https://cn.vitejs.dev/config
|
||||
export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||
const env = loadEnv(mode, process.cwd());
|
||||
return {
|
||||
@@ -53,17 +51,13 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||
* http://localhost:3000/dev-api/users (F12可见请求路径) => http://localhost:8989/users (实际请求后端 API 路径)
|
||||
*
|
||||
* env.VITE_APP_BASE_API: /dev-api
|
||||
* env.VITE_APP_TARGET_URL: http://localhost:8989
|
||||
* env.VITE_APP_TARGET_BASE_API: ""
|
||||
* env.VITE_APP_API_URL: http://localhost:8989
|
||||
*/
|
||||
[env.VITE_APP_BASE_API]: {
|
||||
changeOrigin: true,
|
||||
target: env.VITE_APP_TARGET_URL,
|
||||
target: env.VITE_APP_API_URL,
|
||||
rewrite: (path) =>
|
||||
path.replace(
|
||||
new RegExp("^" + env.VITE_APP_BASE_API),
|
||||
env.VITE_APP_TARGET_BASE_API
|
||||
),
|
||||
path.replace(new RegExp("^" + env.VITE_APP_BASE_API), ""),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -86,8 +80,8 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||
},
|
||||
vueTemplate: true,
|
||||
// 配置文件生成位置(false:关闭自动生成)
|
||||
dts: false,
|
||||
// dts: "src/types/auto-imports.d.ts",
|
||||
//dts: false,
|
||||
dts: "src/types/auto-imports.d.ts",
|
||||
}),
|
||||
|
||||
Components({
|
||||
@@ -100,8 +94,8 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||
// 指定自定义组件位置(默认:src/components)
|
||||
dirs: ["src/components", "src/**/components"],
|
||||
// 配置文件位置 (false:关闭自动生成)
|
||||
dts: false,
|
||||
// dts: "src/types/components.d.ts",
|
||||
// dts: false,
|
||||
dts: "src/types/components.d.ts",
|
||||
}),
|
||||
|
||||
Icons({
|
||||
@@ -109,7 +103,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||
}),
|
||||
createSvgIconsPlugin({
|
||||
// 指定需要缓存的图标文件夹
|
||||
iconDirs: [path.resolve(pathSrc, "assets/icons")],
|
||||
iconDirs: [resolve(pathSrc, "assets/icons")],
|
||||
// 指定symbolId格式
|
||||
symbolId: "icon-[dir]-[name]",
|
||||
}),
|
||||
@@ -173,6 +167,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||
"element-plus/es/components/notification/style/css",
|
||||
"element-plus/es/components/image/style/css",
|
||||
"element-plus/es/components/statistic/style/css",
|
||||
"element-plus/es/components/watermark/style/css",
|
||||
"@vueuse/core",
|
||||
"sortablejs",
|
||||
"path-to-regexp",
|
||||
|
||||
Reference in New Issue
Block a user