perf(build): 继续优化构建和 lint 执行效率
- 关闭构建 gzip size 统计并调整 chunk 警告阈值 - 移除 Vite dev/build 链路中的 ESLint 和 progress 插件 - 删除未使用的 legacy、terser、ejs、eslint、progress 构建依赖 - 为 ESLint、Stylelint、Prettier 增加缓存脚本 - 新增 lint-staged 配置,仅处理变更文件 perf(lint): 将 ESLint 热缓存耗时从约 16.3s 降到约 1.3smaster-bpm-bug-fix
parent
3d37515cfc
commit
2ea2d9b18f
|
|
@ -1,8 +1,6 @@
|
|||
import { resolve } from 'path'
|
||||
import Vue from '@vitejs/plugin-vue'
|
||||
import VueJsx from '@vitejs/plugin-vue-jsx'
|
||||
import progress from 'vite-plugin-progress'
|
||||
import EslintPlugin from 'vite-plugin-eslint2'
|
||||
// @ts-ignore
|
||||
import ElementPlus from 'unplugin-element-plus/vite'
|
||||
import AutoImport from 'unplugin-auto-import/vite'
|
||||
|
|
@ -28,7 +26,6 @@ export function createVitePlugins(isBuild = false, env: Record<string, string> =
|
|||
Vue(),
|
||||
VueJsx(),
|
||||
UnoCSS(),
|
||||
!isBuild && progress(),
|
||||
ElementPlus({}),
|
||||
AutoImport({
|
||||
include: [
|
||||
|
|
@ -65,11 +62,6 @@ export function createVitePlugins(isBuild = false, env: Record<string, string> =
|
|||
resolvers: [ElementPlusResolver()],
|
||||
globs: ['src/components/**/**.{vue, md}', '!src/components/DiyEditor/components/mobile/**']
|
||||
}),
|
||||
!isBuild && EslintPlugin({
|
||||
cache: false,
|
||||
include: ['src/**/*.vue', 'src/**/*.ts', 'src/**/*.tsx'] // 检查的文件
|
||||
}),
|
||||
|
||||
createSvgIconsPlugin({
|
||||
iconDirs: [pathResolve('src/assets/svgs')],
|
||||
symbolId: 'icon-[dir]-[name]'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
export default {
|
||||
'src/**/*.{js,ts,tsx,vue}': [
|
||||
'eslint --fix --cache --cache-location node_modules/.cache/eslint/',
|
||||
'prettier --write --loglevel warn --cache --cache-location node_modules/.cache/prettier/.prettier-cache'
|
||||
],
|
||||
'src/**/*.{css,less,scss,postcss,vue}': [
|
||||
'stylelint --fix --cache --cache-location node_modules/.cache/stylelint/'
|
||||
],
|
||||
'src/**/*.{json,html,md}': [
|
||||
'prettier --write --loglevel warn --cache --cache-location node_modules/.cache/prettier/.prettier-cache'
|
||||
]
|
||||
}
|
||||
15
package.json
15
package.json
|
|
@ -19,10 +19,14 @@
|
|||
"preview": "pnpm build:local && vite preview",
|
||||
"clean": "npx rimraf node_modules",
|
||||
"clean:cache": "npx rimraf node_modules/.cache",
|
||||
"lint:eslint": "eslint --fix ./src",
|
||||
"lint:format": "prettier --write --loglevel warn \"src/**/*.{js,ts,json,tsx,css,less,scss,vue,html,md}\"",
|
||||
"lint": "pnpm lint:eslint:check && pnpm lint:style:check && pnpm lint:format:check",
|
||||
"lint:eslint": "eslint --fix ./src --cache --cache-location node_modules/.cache/eslint/",
|
||||
"lint:eslint:check": "eslint ./src --cache --cache-location node_modules/.cache/eslint/",
|
||||
"lint:format": "prettier --write --loglevel warn --cache --cache-location node_modules/.cache/prettier/.prettier-cache \"src/**/*.{js,ts,json,tsx,css,less,scss,vue,html,md}\"",
|
||||
"lint:format:check": "prettier --check --cache --cache-location node_modules/.cache/prettier/.prettier-cache \"src/**/*.{js,ts,json,tsx,css,less,scss,vue,html,md}\"",
|
||||
"lint:style": "stylelint --fix \"./src/**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
|
||||
"lint:lint-staged": "lint-staged -c "
|
||||
"lint:style:check": "stylelint \"./src/**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
|
||||
"lint:lint-staged": "lint-staged"
|
||||
},
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "2.3.2",
|
||||
|
|
@ -99,7 +103,6 @@
|
|||
"@unocss/eslint-config": "^66.6.8",
|
||||
"@unocss/eslint-plugin": "66.6.8",
|
||||
"@unocss/transformer-variant-group": "^66.6.8",
|
||||
"@vitejs/plugin-legacy": "^8.0.1",
|
||||
"@vitejs/plugin-vue": "^6.0.6",
|
||||
"@vitejs/plugin-vue-jsx": "^5.1.5",
|
||||
"autoprefixer": "^10.5.0",
|
||||
|
|
@ -122,7 +125,6 @@
|
|||
"stylelint-config-recommended": "^18.0.0",
|
||||
"stylelint-config-standard": "^40.0.0",
|
||||
"stylelint-order": "^8.1.1",
|
||||
"terser": "^5.46.2",
|
||||
"typescript": "6.0.3",
|
||||
"typescript-eslint": "^8.59.2",
|
||||
"unocss": "^66.6.8",
|
||||
|
|
@ -131,9 +133,6 @@
|
|||
"unplugin-vue-components": "^32.0.0",
|
||||
"vite": "8.0.10",
|
||||
"vite-plugin-compression": "^0.5.1",
|
||||
"vite-plugin-ejs": "^1.7.0",
|
||||
"vite-plugin-eslint2": "^5.1.0",
|
||||
"vite-plugin-progress": "^0.0.7",
|
||||
"vite-plugin-svg-icons-ng": "^1.9.0",
|
||||
"vue-eslint-parser": "^10.4.0",
|
||||
"vue-tsc": "^3.2.8"
|
||||
|
|
|
|||
1259
pnpm-lock.yaml
1259
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
|
@ -80,8 +80,10 @@ export default ({command, mode}: ConfigEnv): UserConfig => {
|
|||
]
|
||||
},
|
||||
build: {
|
||||
chunkSizeWarningLimit: 2000,
|
||||
minify: 'oxc',
|
||||
outDir: env.VITE_OUT_DIR || 'dist',
|
||||
reportCompressedSize: false,
|
||||
sourcemap: env.VITE_SOURCEMAP === 'true' ? 'inline' : false,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue