feat: Add `optimizeDeps` config for Vite (#96)

This commit is contained in:
CharleeWa 2024-05-14 09:49:40 +08:00
parent d0f1543c2e
commit 2641393677
3 changed files with 28 additions and 1 deletions

24
build/vite/optimize.ts Normal file
View File

@ -0,0 +1,24 @@
const include = [
'axios',
'store',
'echarts',
'lodash-es',
'resize-detector',
'store/plugins/expire',
'vant/es/cell-group/style/index',
'vant/es/popup/style/index',
'vant/es/picker/style/index',
'vant/es/cell/style/index',
'vant/es/switch/style/index',
'vant/es/space/style/index',
'vant/es/button/style/index',
'vant/es/empty/style/index',
'vant/es/icon/style/index',
'vant/es/stepper/style/index',
]
const exclude = [
'@iconify-json/carbon',
]
export { include, exclude }

View File

@ -2,7 +2,7 @@
"name": "vue3-vant-mobile",
"type": "module",
"version": "2.3.2",
"packageManager": "pnpm@9.0.6",
"packageManager": "pnpm@9.1.1",
"description": "Vue + Vite H5 Starter Template",
"license": "MIT",
"scripts": {

View File

@ -5,6 +5,7 @@ import type { ConfigEnv, UserConfig } from 'vite'
import viewport from 'postcss-mobile-forever'
import autoprefixer from 'autoprefixer'
import { createVitePlugins } from './build/vite'
import { exclude, include } from './build/vite/optimize'
export default ({ mode }: ConfigEnv): UserConfig => {
const root = process.cwd()
@ -56,5 +57,7 @@ export default ({ mode }: ConfigEnv): UserConfig => {
cssCodeSplit: false,
chunkSizeWarningLimit: 2048,
},
optimizeDeps: { include, exclude },
}
}