From 41e12925ebca12182e2713a63a2441ed23f4dfff Mon Sep 17 00:00:00 2001 From: CharleeWa <18888351756@163.com> Date: Thu, 23 May 2024 14:37:29 +0800 Subject: [PATCH] feat: add optimizeDeps config for Vite --- build/vite/optimize.ts | 20 ++++++++++++++++++++ vite.config.ts | 3 +++ 2 files changed, 23 insertions(+) create mode 100644 build/vite/optimize.ts diff --git a/build/vite/optimize.ts b/build/vite/optimize.ts new file mode 100644 index 0000000..a3211fa --- /dev/null +++ b/build/vite/optimize.ts @@ -0,0 +1,20 @@ +const include = [ + 'axios', + 'store', + 'echarts', + 'lodash-es', + 'resize-detector', + 'store/plugins/expire', + '@varlet/ui/es/paper/style/index.mjs', + '@varlet/ui/es/cell/style/index.mjs', + '@varlet/ui/es/switch/style/index.mjs', + '@varlet/ui/es/picker/style/index.mjs', + '@varlet/ui/es/counter/style/index.mjs', + '@varlet/ui/es/space/style/index.mjs', +] + +const exclude = [ + '@iconify-json/carbon', +] + +export { include, exclude } diff --git a/vite.config.ts b/vite.config.ts index fe603f8..867fbab 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -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() @@ -51,5 +52,7 @@ export default ({ mode }: ConfigEnv): UserConfig => { cssCodeSplit: false, chunkSizeWarningLimit: 2048, }, + + optimizeDeps: { include, exclude }, } }