Files
work-leave-front/preview.vite.config.ts
wanghu 2e36d7a9c8
build / build (push) Successful in 9m55s
commit
2026-10-10 15:58:02 +08:00

52 lines
1.9 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 教师时长页本地预览专用 vite 配置(不影响业务开发/构建)
// 用法:
// node preview-ut/mock-server.mjs# mock 数据(8109)
// npx vite --config preview.vite.config.ts --port 8099
// 打开 http://localhost:8099/preview-ut.html
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
import ViteAutoImport from "unplugin-auto-import/vite";
import UnoCSS from "@unocss/vite";
import presetUno from "@unocss/preset-uno";
import presetRemToPx from "@unocss/preset-rem-to-px";
export default defineConfig({
root: __dirname,
base: "./",
plugins: [
vue(),
createSvgIconsPlugin({
iconDirs: [path.resolve(process.cwd(), "src/assets/icons")],
symbolId: "icon-[dir]-[name]",
inject: "body-last",
customDomId: "__svg__icons__dom__",
}),
ViteAutoImport({
imports: ["vue", "vue-router", { "view-ui-plus": ["Button", "Table", "Modal", "Message", "Form", "FormItem", "Input", "Select"] }],
dts: false,
dirs: ["src/api/module"],
}),
UnoCSS(),
],
resolve: {
alias: { "@": path.resolve(__dirname, "./src") },
},
// 独立依赖缓存目录,避免与业务 dev(8078/8079) 互相触发「重新预构建 → 删除 deps 目录」
// 被安全删除守卫拦截(单轮删除项数超阈值)
cacheDir: "node_modules/.vite-preview",
css: {
preprocessorOptions: {
scss: {},
},
},
server: {
host: "localhost",
port: 8099,
// 预览专用:转发到本地 mock 服务,绕开后端 CAS(无登录态时后端返 302 触发 SSO 跳转)
proxy: {
"/api": { target: "http://localhost:8109", changeOrigin: true },
},
},
});