feat: 更新构建脚本,添加类型检查命令并优化Vite配置,调整chunk大小限制和文件命名格式
This commit is contained in:
@@ -38,7 +38,8 @@
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"build": "vite build",
|
||||
"build:check": "tsc && vite build",
|
||||
"preview": "vite preview",
|
||||
"lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
|
||||
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,scss,css}\"",
|
||||
|
||||
@@ -1,27 +1,41 @@
|
||||
import { defineConfig } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import path from "path";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve("src"),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
open: true,
|
||||
},
|
||||
build: {
|
||||
chunkSizeWarningLimit: 1500, // 提高警告阈值,减少无关警告
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks: {
|
||||
"react-vendor": ["react", "react-dom"],
|
||||
"antd-vendor": ["antd", "@ant-design/icons", "antd-mobile"],
|
||||
"echarts-vendor": ["echarts", "echarts-for-react"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
import { defineConfig } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import path from "path";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve("src"),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
open: true,
|
||||
},
|
||||
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,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user