feat: 🚀 表单设计器和审批流本地化
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { defineConfig, loadEnv, ConfigEnv, UserConfig } from "vite";
|
||||
import { defineConfig, loadEnv, ConfigEnv, UserConfig, CSSOptions } from "vite";
|
||||
import { resolve } from "path";
|
||||
import { wrapperEnv } from "./build/getEnv";
|
||||
import { createProxy } from "./build/proxy";
|
||||
import { createVitePlugins } from "./build/plugins";
|
||||
import postcssImport from "postcss-import";
|
||||
import UnoCSS from "unocss/vite";
|
||||
import pkg from "./package.json";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
@@ -13,7 +13,6 @@ const __APP_INFO__ = {
|
||||
lastBuildTime: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
};
|
||||
|
||||
// @see: https://vitejs.dev/config/
|
||||
export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||
const root = process.cwd();
|
||||
const env = loadEnv(mode, root);
|
||||
@@ -30,64 +29,38 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||
define: {
|
||||
__APP_INFO__: JSON.stringify(__APP_INFO__)
|
||||
},
|
||||
// 关键:通过 as CSSOptions 断言类型
|
||||
css: {
|
||||
postcss: {
|
||||
plugins: [
|
||||
postcssImport({
|
||||
// 排除 node_modules 目录,不解析其中的 CSS
|
||||
path: [],
|
||||
resolve(id: any) {
|
||||
if (id.startsWith("node_modules/")) {
|
||||
return false; // 跳过 node_modules 中的文件
|
||||
}
|
||||
return id;
|
||||
}
|
||||
})
|
||||
]
|
||||
},
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
silenceDeprecations: ["legacy-js-api"],
|
||||
additionalData: `@use "@/styles/var.scss" as *;`
|
||||
}
|
||||
},
|
||||
warnings: {
|
||||
filter: (warning: any) => {
|
||||
return !warning.message.includes('A nested style rule cannot start with "a"');
|
||||
}
|
||||
}
|
||||
// // 可以配置 CSS Modules 等其他合法选项
|
||||
// modules: {
|
||||
// // 例如:自定义 CSS Modules 类名格式
|
||||
// generateScopedName: mode === "production" ? "[hash:base64:8]" : "[name]-[local]-[hash:base64:5]"
|
||||
// }
|
||||
},
|
||||
} as CSSOptions, // 类型断言,解决类型不匹配
|
||||
server: {
|
||||
host: "0.0.0.0",
|
||||
port: viteEnv.VITE_PORT,
|
||||
open: viteEnv.VITE_OPEN,
|
||||
cors: true,
|
||||
// Load proxy configuration from .env.development
|
||||
proxy: createProxy(viteEnv.VITE_PROXY)
|
||||
},
|
||||
plugins: createVitePlugins(viteEnv),
|
||||
plugins: [...createVitePlugins(viteEnv), UnoCSS()],
|
||||
esbuild: {
|
||||
//"console.log",
|
||||
pure: viteEnv.VITE_DROP_CONSOLE ? ["console.log", "debugger"] : []
|
||||
},
|
||||
build: {
|
||||
outDir: "dist",
|
||||
minify: "esbuild",
|
||||
// esbuild 打包更快,但是不能去除 console.log,terser打包慢,但能去除 console.log
|
||||
// minify: "terser",
|
||||
// terserOptions: {
|
||||
// compress: {
|
||||
// drop_console: viteEnv.VITE_DROP_CONSOLE,
|
||||
// drop_debugger: true
|
||||
// }
|
||||
// },
|
||||
// 禁用 gzip 压缩大小报告,可略微减少打包时间
|
||||
reportCompressedSize: false,
|
||||
// 规定触发警告的 chunk 大小
|
||||
chunkSizeWarningLimit: 2000,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
// Static resource classification and packaging
|
||||
chunkFileNames: "assets/js/[name]-[hash].js",
|
||||
entryFileNames: "assets/js/[name]-[hash].js",
|
||||
assetFileNames: "assets/[ext]/[name]-[hash].[ext]"
|
||||
|
||||
Reference in New Issue
Block a user