unplugin-liv-web
LivWeb2按需自动导入插件。
特性
- ✨ 支持自动按需导入组件和指令.
- 🏝 支持Tree Shaking, 只会自动注册使用过的组件.
- 🦾 完全支持TypeScript类型安全.
安装
bash
npm i unplugin-liv-web -D使用
ts
// vite.config.ts
import Components from 'unplugin-vue-components/vite';
import { LivWebResolver } from 'unplugin-liv-web';
export default defineConfig({
plugins: [
Components({
resolvers: [LivWebResolver()],
}),
],
});参数
你可以在创建LivWebResolver时对自动导入参数进行配置。
ts
// vite.config.ts
import Components from 'unplugin-vue-components/vite';
import { LivWebResolver } from 'unplugin-liv-web';
// 以Liv开头但不是LivWeb组件库的组件可以通过以下正则表达式排除
const pattern = /^(LivMyComponent1|LivMyComponent2|LivMyComponent3)$/;
export default defineConfig({
plugins: [
Components({
resolvers: [LivWebResolver({ importStyle: 'sass', exclude: pattern })],
}),
],
});| 参数名 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| importStyle | 自动导入的组件样式类型 | boolean | 'css' | 'sass' | css |
| ssr | 是否开启ssr | boolean | false |
| directives | 是否自动导入指令 | boolean | true |
| exclude | 需要排除的文件 | RegExp | — |
| noStylesComponents | 无样式组件列表 | string[] | [] |
更新日志
1.0.2 (2024-10-28)
Features
- 支持自动导入
v-authority权限校验指令(877d5f5)
1.0.1 (2024-09-18)
Bug Fixes
- 修复无法自动导入自定义指令的问题(6242b99)
1.0.0 (2024-09-13)
Features
- 自动导入Liv Web库组件
- 自动导入Liv Web库指令
- 支持配置导入样式类型
- 支持配置是否开启SSR
- 支持配置是否导入指令
- 支持配置排除文件
- 支持配置无样式组件
