feat: 20250610 深度优化图片(提升首屏速度)

This commit is contained in:
mac·ufutx 2025-06-10 17:15:13 +08:00
parent 6b0391bf2e
commit db264fb08b
2 changed files with 15 additions and 2 deletions

View File

@ -7,6 +7,7 @@
"dev": "vite",
"build": "vue-tsc -b && vite build",
"preview": "vite preview",
"audit": "npm audit --fix",
"lint": "eslint . --ext .vue,.js,.jsx,.ts,.tsx --fix --max-warnings 0",
"lint:check": "eslint . --ext .vue,.js,.jsx,.ts,.tsx",
"prepare": "husky install",
@ -49,7 +50,7 @@
"prettier": "^3.5.3",
"typescript": "5.1.6",
"vite": "^4.4.9",
"vite-plugin-image-optimizer": "^1.1.8",
"vite-plugin-imagemin": "^0.6.1",
"vue-tsc": "1.8.14"
}
}

View File

@ -2,8 +2,20 @@ import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path' // 引入 path 模块
import viteImagemin from 'vite-plugin-imagemin' // 新插件
export default defineConfig({
plugins: [vue()],
plugins: [
vue(),
viteImagemin({
// 基础压缩配置(可根据需求扩展)
gifsicle: { optimizationLevel: 7 },
optipng: { optimizationLevel: 7 },
mozjpeg: { quality: 80 },
pngquant: { quality: [0.8, 0.9] },
svgo: { plugins: [{ name: 'removeViewBox' }] }
})
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src') // 添加路径别名