fix(frontend): 修复 Vite 缓存过期导致 element-plus 入口解析失败
问题原因: - Vite dev server 长时间运行(跨天)后 deps 缓存过期 - import-analysis 阶段无法解析 element-plus 包入口 - 报错: Failed to resolve entry for package "element-plus" 解决方案: - vite.config.js 添加 optimizeDeps.include 显式预构建 element-plus 等核心依赖 - package.json 添加 predev 脚本, npm run dev 前自动清 .vite 缓存 - 防止其他服务器 git pull 后同样踩坑
This commit is contained in:
@@ -11,6 +11,18 @@ export default defineConfig({
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||
}
|
||||
},
|
||||
// 显式预构建 element-plus,避免 Vite 缓存过期后
|
||||
// 出现 "Failed to resolve entry for package element-plus" 错误
|
||||
optimizeDeps: {
|
||||
include: [
|
||||
'element-plus',
|
||||
'@element-plus/icons-vue',
|
||||
'vue',
|
||||
'vue-router',
|
||||
'pinia',
|
||||
'axios'
|
||||
]
|
||||
},
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 3000,
|
||||
|
||||
Reference in New Issue
Block a user