Skip to content

Commit fd2a634

Browse files
committed
docs: UI libraries resolvers
1 parent f538eac commit fd2a634

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,58 @@ export default {
101101
}
102102
```
103103

104+
## Importing from UI Libraries
105+
106+
We have several built-in resolver for popular UI libraries like [Ant Design Vue](https://antdv.com/) and [Element Plus](https://element-plus.org/), where you can enable them by:
107+
108+
```ts
109+
// vite.config.js
110+
import ViteComponents, {
111+
AntDesignVueResolver,
112+
ElementPlusResolver,
113+
VantResolver,
114+
} from 'vite-plugin-components'
115+
116+
export default {
117+
plugins: [
118+
/* ... */
119+
ViteComponents({
120+
customResolvers: [
121+
AntDesignVueResolver(),
122+
ElementPlusResolver(),
123+
VantResolver(),
124+
]
125+
}),
126+
],
127+
}
128+
```
129+
130+
Or you can write your own resolver quite easily:
131+
132+
```ts
133+
// vite.config.js
134+
import ViteComponents from 'vite-plugin-components'
135+
136+
export default {
137+
plugins: [
138+
/* ... */
139+
ViteComponents({
140+
customResolvers: [
141+
// example of importing Vant
142+
(name) => {
143+
// where `name` is always CapitalCase
144+
if (name.startsWith('Van'))
145+
return { importName: name.slice(3), path: 'vant' }
146+
}
147+
]
148+
}),
149+
],
150+
}
151+
```
152+
153+
If made other UI libraries configured, please feel free to contribute so it can help others using them out-of-box. Thanks!
154+
155+
104156
## Configuration
105157

106158
The following show the default values of the configuration

0 commit comments

Comments
 (0)