2025-09-11 15:00:57 +08:00
|
|
|
import { defineConfig } from "vite";
|
|
|
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
|
import path from "path";
|
|
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
plugins: [react()],
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
"@": path.resolve("src"),
|
2025-10-23 12:35:30 +08:00
|
|
|
"@storeModule": path.resolve("src/store/module/"),
|
|
|
|
|
"@weChatStore": path.resolve("src/store/module/weChat"),
|
|
|
|
|
"@apiModule": path.resolve("src/api/module/"),
|
2025-10-23 18:56:16 +08:00
|
|
|
"@utils": path.resolve("src/utils/"),
|
2025-09-11 15:00:57 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
server: {
|
|
|
|
|
open: true,
|
2025-12-26 18:15:33 +08:00
|
|
|
port: 8888,
|
2025-09-11 15:00:57 +08:00
|
|
|
host: "0.0.0.0",
|
|
|
|
|
},
|
|
|
|
|
build: {
|
|
|
|
|
chunkSizeWarningLimit: 2000,
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
output: {
|
|
|
|
|
// 减少文件数量,合并更多依赖
|
|
|
|
|
manualChunks: {
|
|
|
|
|
// 核心框架
|
|
|
|
|
vendor: ["react", "react-dom", "react-router-dom"],
|
|
|
|
|
// UI组件库
|
|
|
|
|
ui: ["antd", "@ant-design/icons", "antd-mobile"],
|
|
|
|
|
// 工具库
|
|
|
|
|
utils: ["axios", "dayjs", "zustand"],
|
|
|
|
|
// 图表库
|
|
|
|
|
charts: ["echarts", "echarts-for-react"],
|
|
|
|
|
},
|
|
|
|
|
// 文件名格式
|
|
|
|
|
chunkFileNames: "assets/[name]-[hash].js",
|
|
|
|
|
entryFileNames: "assets/[name]-[hash].js",
|
|
|
|
|
assetFileNames: "assets/[name]-[hash].[ext]",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
// 启用压缩
|
|
|
|
|
minify: "esbuild",
|
|
|
|
|
// 启用源码映射(可选,生产环境可以关闭)
|
|
|
|
|
sourcemap: false,
|
|
|
|
|
// 生成manifest文件
|
|
|
|
|
manifest: true,
|
|
|
|
|
},
|
|
|
|
|
define: {
|
|
|
|
|
// 注入版本信息
|
|
|
|
|
"import.meta.env.VITE_APP_VERSION": JSON.stringify(
|
|
|
|
|
process.env.npm_package_version,
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
});
|