feat: 接入 UserHome 前端业务代码(含真实 src/依赖,保留 projman 标准 CI)
This commit is contained in:
+15
-68
@@ -3,25 +3,12 @@ import { createHtmlPlugin } from "vite-plugin-html";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import path, { resolve } from "path";
|
||||
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
|
||||
import { viteMockServe } from "vite-plugin-mock";
|
||||
import ViteAutoImport from "unplugin-auto-import/vite";
|
||||
import usePluginImport from "vite-plugin-importer";
|
||||
// import { viteMockServe } from "vite-plugin-mock";
|
||||
// export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => {
|
||||
|
||||
import UnoCSS from "@unocss/vite";
|
||||
import presetUno from "@unocss/preset-uno";
|
||||
|
||||
import presetRemToPx from "@unocss/preset-rem-to-px";
|
||||
|
||||
// 构建输出:兼容既有 CI 的 mode 子目录(build:prod → dist/prod、build:ld → dist/ld、build:base → dist/base);
|
||||
// 新命令 `vite build`(默认 production mode)→ dist/。.env.base/ld/prod 均已删除,
|
||||
// 各 mode 产物内容完全相同(VITE_* 恒 undefined),不存在按环境烧值问题。
|
||||
// dev 读 .env.dev(import.meta.env.VITE_*);build 时 .env/.env.production 不存在 → VITE_* 全 undefined,
|
||||
// host.config.ts 自动跳过 → 线上仅走 env-config 接口。注意:勿新建 .env.production / .env。
|
||||
export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => {
|
||||
const subDir = mode === "ld" || mode === "prod" ? mode : mode === "base" ? mode : "";
|
||||
const outDir = command === "build" && subDir ? `dist/${subDir}` : "dist";
|
||||
|
||||
return {
|
||||
plugins: [
|
||||
export default {
|
||||
plugins: [
|
||||
vue(),
|
||||
createSvgIconsPlugin({
|
||||
iconDirs: [resolve(process.cwd(), "src/assets/icons")],
|
||||
@@ -29,24 +16,13 @@ export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => {
|
||||
inject: "body-last", // 插入的位置
|
||||
customDomId: "__svg__icons__dom__", // svg的id
|
||||
}),
|
||||
viteMockServe({
|
||||
mockPath: "./src/assets/mock",
|
||||
}),
|
||||
ViteAutoImport({
|
||||
imports: [
|
||||
"vue",
|
||||
"vue-router",
|
||||
{
|
||||
"view-ui-plus": ["Button", "Table", "Modal", "Message", "Form", "FormItem", "Input", "Select"],
|
||||
},
|
||||
{
|
||||
from: "alova/client",
|
||||
imports: ["usePagination", "useRequest", "useWatcher", "useForm"],
|
||||
},
|
||||
],
|
||||
dts: "./src/auto-imports.d.ts",
|
||||
dirs: ["src/api"], // 自动导入 hooks
|
||||
}),
|
||||
// usePluginImport({
|
||||
// libraryName: "view-ui-plus",
|
||||
// libraryDirectory: "src/components",
|
||||
// }),
|
||||
// viteMockServe({
|
||||
// mockPath: "./src/assets/mock",
|
||||
// }),
|
||||
createHtmlPlugin({
|
||||
minify: true,
|
||||
pages: [
|
||||
@@ -56,40 +32,12 @@ export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => {
|
||||
filename: "index.html",
|
||||
injectOptions: {
|
||||
data: {
|
||||
title: "用户中心",
|
||||
injectScript: ``,
|
||||
title: "数字基座",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
UnoCSS({
|
||||
presets: [
|
||||
presetUno(), // 核心预设(Tailwind风格)
|
||||
presetRemToPx({ baseFontSize: 4 }), // 1单位=1px(去rem化)
|
||||
],
|
||||
shortcuts: {
|
||||
// 布局
|
||||
"flex-center": "flex items-center justify-center",
|
||||
// 常用组件
|
||||
btn: "px-16px py-8px rounded-4px cursor-pointer transition-all duration-200",
|
||||
"btn-primary": "bg-blue-600 text-white hover:bg-blue-700",
|
||||
card: "bg-white rounded-8px shadow-md p-16px",
|
||||
// 文本截断
|
||||
"text-ellipsis": "truncate",
|
||||
"text-multi-ellipsis": "line-clamp-2",
|
||||
},
|
||||
theme: {
|
||||
fontSize: {
|
||||
xs: "12px",
|
||||
sm: "14px",
|
||||
base: "16px",
|
||||
lg: "18px",
|
||||
xl: "20px",
|
||||
"2xl": "24px",
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
@@ -120,7 +68,7 @@ export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => {
|
||||
base: "./",
|
||||
build: {
|
||||
target: "modules", //设置最终构建的浏览器兼容目标 //es2015(编译成es5) | modules
|
||||
outDir, // 构建输出目录:兼容 CI 的 dist/{prod|ld|base} 子目录(见文件头注释)
|
||||
outDir: "dist", // 构建得包名 默认:dist
|
||||
assetsDir: "assets", // 静态资源得存放路径文件名 assets
|
||||
sourcemap: false, //构建后是否生成 source map 文件
|
||||
minify: "esbuild", // 项目压缩 :boolean | 'terser' | 'esbuild'
|
||||
@@ -146,5 +94,4 @@ export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => {
|
||||
manualEntrypoint: "index.html",
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user