fix(frontend): 移除 element-plus alias 防止 CSS 路径解析失败

问题原因:
- 上次提交在 vite.config.js resolve.alias 中将 element-plus
  直接映射到 es/index.mjs 文件路径
- 这导致 import 'element-plus/dist/index.css' 时,
  Vite 拼接路径为 es/index.mjs/dist/index.css,文件不存在
- 报错: Failed to resolve import 'element-plus/dist/index.css'

解决方案:
- 移除 element-plus 的 resolve.alias 映射
- 包名保留为包名,Vite 的 node_modules 解析机制可正确处理
  element-plus 的 JS 入口和 CSS 路径
- start.sh 已有清缓存+自动重试机制兜底
This commit is contained in:
Your Name
2026-07-23 15:05:35 +08:00
parent 094d2cc112
commit ee0552f837
+1 -6
View File
@@ -1,5 +1,4 @@
import { fileURLToPath, URL } from 'node:url' import { fileURLToPath, URL } from 'node:url'
import path from 'node:path'
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue'
@@ -9,11 +8,7 @@ export default defineConfig({
plugins: [vue()], plugins: [vue()],
resolve: { resolve: {
alias: { alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)), '@': fileURLToPath(new URL('./src', import.meta.url))
// 兜底:若 element-plus exports 解析失败则走 fallback
'element-plus': path.resolve(
fileURLToPath(new URL('node_modules/element-plus/es/index.mjs', import.meta.url))
)
} }
}, },
server: { server: {