108 Star 954 Fork 377

smallwei/avue-cli

 / 详情

打包后 element-plus lib跟es版本都会被打包进去

Backlog
Opened this issue  
2024-03-06 18:55

输入图片说明

Comments (3)

Jackliu created任务

有没有好的改进方案 可以pr一下

估计是因为 avue使用的require方式用element-plus 所以是lib
vite默认是es版本

解决方案:
先把所有es的引用改成lib,例如 import elementEnLocale from 'element-plus/es/locale/lang/en'改为import elementEnLocale from 'element-plus/lib/locale/lang/en'
一种方案是把所有element-plus的引用改成 element-plug/lib
另一种是改vite 别名配置

alias: [
       { find: '~', replacement: resolve(__dirname, './') },
       { find: '@', replacement: resolve(__dirname, './src') },
       { find: 'components', replacement: resolve(__dirname, './src/components') },
       { find: 'styles', replacement: resolve(__dirname, './src/styles') },
       { find: 'utils', replacement: resolve(__dirname, './src/utils') },
       { find: /^element-plus$/, replacement: 'element-plus/lib' },
     ]

element-plus 升级到2.3.8及以上版本后无法使用'element-plus/lib'
最后的方案是

 { find: /^element-plus$/, replacement: 'element-plus/dist/index.full.min.js' },
import elementEnLocale from 'element-plus/dist/locale/en.js'

Sign in to comment

Status
Assignees
Milestones
Pull Requests
Successfully merging a pull request will close this issue.
Branches
Planed to start   -   Planed to end
-
Top level
Priority
参与者(2)
632261 smallweigit 1588214431 995540 jackliulovelt 1578937776
JavaScript
1
https://gitee.com/smallweigit/avue-cli.git
git@gitee.com:smallweigit/avue-cli.git
smallweigit
avue-cli
avue-cli

Search