Closed nhpupu closed 2 years ago
在npm中的@element-plus/icons-vue包无法被vite treeshake。打包后,会把全部icon都打入包中。
反而是被标为deprecated的@element-plus/icons包可以被treeshake。
直接从node_modules中的文件就能看出区别。
pnpm create vite
pnpm i @element-plus/icons @element-plus/icons-vue
pnpm build
可以发现从不同的包引用icon时,输出文件的大小有区别(53KB vs 255KB)。 输出文件中http://www.w3.org/2000/svg字符串的出现数目也能说明问题。
http://www.w3.org/2000/svg
请尝试使用最新版本
确认在@element-plus/icons-vue@2.0.4中问题已修复
在npm中的@element-plus/icons-vue包无法被vite treeshake。打包后,会把全部icon都打入包中。
反而是被标为deprecated的@element-plus/icons包可以被treeshake。
版本
复现
直接从node_modules中的文件就能看出区别。
pnpm create vite
创建一个vite vue-ts项目pnpm i @element-plus/icons @element-plus/icons-vue
pnpm build
可以发现从不同的包引用icon时,输出文件的大小有区别(53KB vs 255KB)。 输出文件中
http://www.w3.org/2000/svg
字符串的出现数目也能说明问题。