R1 先行批:问卷前端(Notice 模板移植 8 页面,tsc/vite build 通过)+ 菜单契约说明
build / build (push) Successful in 1m50s

This commit is contained in:
chenxing
2026-10-22 10:14:39 +08:00
parent 14269d0dae
commit 2d110498cd
81 changed files with 13248 additions and 2 deletions
+138
View File
@@ -0,0 +1,138 @@
import { ConfigEnv, UserConfig, defineConfig } from "vite";
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 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(({ command, mode }: ConfigEnv): UserConfig => {
const outDir = "dist";
return {
plugins: [
vue(),
createSvgIconsPlugin({
iconDirs: [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"],
},
{
from: "alova/client",
imports: ["usePagination", "useRequest", "useWatcher", "useForm"],
},
],
dts: "./src/auto-imports.d.ts",
dirs: ["src/api"],
}),
createHtmlPlugin({
minify: true,
pages: [
{
entry: "src/main.ts",
template: "index.html",
filename: "index.html",
injectOptions: {
data: {
title: "问卷管理",
injectScript: ``,
},
},
},
],
}),
UnoCSS({
presets: [
presetUno(),
presetRemToPx({ baseFontSize: 4 }),
],
shortcuts: {
"flex-center": "flex items-center justify-center",
btn: "px-16px py-8px rounded-4px cursor-pointer transition-all duration-200",
card: "bg-white rounded-8px shadow-md p-16px",
"text-ellipsis": "truncate",
},
theme: {
fontSize: {
xs: "12px",
sm: "14px",
base: "16px",
lg: "18px",
xl: "20px",
"2xl": "24px",
},
},
}),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
server: {
host: "localhost",
port: 8091,
proxy: {
// 问卷后端(question-center :8090):同源代理规避 CAS 过滤器不回 CORS 头
"/api": {
target: "http://localhost:8090",
changeOrigin: true,
},
// FC 后端(form-center :8086):前端以登录会话直调 FC /api/form/**(create/config/get/
// fillable/copy 等),rewrite 去掉 /fcapi 前缀;credentials:"include"(localhost 各端口
// 共享 Cookie 域,会话互通)
"/fcapi": {
target: "http://localhost:8086",
changeOrigin: true,
rewrite: (p: string) => p.replace(/^\/fcapi/, ""),
},
// 主题通道本地联调(生产同源;YH_THEME_PROXY_TARGET 覆盖本地通道源)
"/static": {
target: process.env.YH_THEME_PROXY_TARGET || "http://base.yunhaixingtong.com",
changeOrigin: true,
},
},
},
css: {},
base: "./",
build: {
target: "modules",
outDir,
assetsDir: "assets",
sourcemap: false,
minify: "esbuild",
chunkSizeWarningLimit: 1000,
cssTarget: "chrome61",
rollupOptions: {
input: {
main: resolve("index.html"),
},
output: {
chunkFileNames: "static/js/[name]-[hash].js",
entryFileNames: "static/js/[name]-[hash].js",
assetFileNames: (assetInfo: any) => {
if (assetInfo.type === "asset" && /\.(jpe?g|png|gif|svg)$/i.test(assetInfo.name)) {
return "static/img/[name].[hash][ext]";
}
if (assetInfo.type === "asset" && /\.(ttf|woff|woff2|eot)$/i.test(assetInfo.name)) {
return "static/fonts/[name].[hash][ext]";
}
return "static/[ext]/[name]-[hash].[ext]";
},
},
},
},
};
});