vant-ui/vant-demo

demo里好像没有看到vite+ts+vant3按需引入的版本,只有bable-impo-plugin的, ts-import-plugin怎么使用

CloudyBao opened this issue · 1 comments

已添加对应的 demo

Originally posted by @chenjiahan in #76 (comment)

@BaoXianSheng 看这个https://tech.youzan.com/vant-3-release/

许多喜欢尝鲜的小伙伴已经在使用 Vite 进行开发了,在使用 Vite 的过程中,经常令大家困惑的一点是,如何在 Vite 中进行按需引入 Vant 组件。在 Vue Cli 中,我们可以通过 babel-plugin-import 插件实现按需引入,但在 Vite 中无法使用该插件。

其实在 Vite 中无须考虑按需引入的问题。Vite 在构建代码时,会自动通过 Tree Shaking 移除未使用的 ESM 模块。而 Vant 3.0 内部所有模块都是基于 ESM 编写的,天然具备按需引入的能力。现阶段遗留的问题是,未使用的组件样式无法被 Tree Shaking 识别并移除,后续我们会考虑通过 Vite 插件的方式进行支持。