Skip to content

Commit a433870

Browse files
committed
feat(core/resolvers/antdv.ts): modify options.resolvePrefix to options.prefix
- You can use options.prefix to customize prefix whatever you want.
1 parent b8c5bc6 commit a433870

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/core/resolvers/antdv.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ export interface AntDesignVueResolverOptions {
200200
*/
201201
packageName?: string
202202
/**
203-
* resolve prefix 'A' ?
203+
* customize prefix of component
204204
*/
205-
resolvePrefix?: boolean
205+
prefix?: string
206206
}
207207

208208
function getStyleDir(compName: string): string {
@@ -272,17 +272,18 @@ export function AntDesignVueResolver(options: AntDesignVueResolverOptions = {
272272
return {
273273
type: 'component',
274274
resolve: (name: string) => {
275+
// if options.prefix is undefined, then give it a default value 'A'
276+
options.prefix === undefined && (options.prefix = 'A')
275277
if (options.resolveIcons && name.match(/(Outlined|Filled|TwoTone)$/)) {
276278
return {
277279
name,
278280
from: '@ant-design/icons-vue',
279281
}
280282
}
281-
// if options.resolvePrefix is undefined or true,
282-
// then eg.'ALayout' -> 'Layout',
283-
// and use `name` directly in the following content
284-
(options?.resolvePrefix === undefined || options.resolvePrefix) && (name = name.slice(1))
285-
if (isAntdv(name) && !options?.exclude?.includes(name)) {
283+
let prefix
284+
// divide component name and prefix
285+
[name, prefix] = [name.slice(options.prefix.length), name.slice(0, options.prefix.length)]
286+
if (prefix === options.prefix && isAntdv(name) && !options?.exclude?.includes(name)) {
286287
const { cjs = false, packageName = 'ant-design-vue' } = options
287288
const path = `${packageName}/${cjs ? 'lib' : 'es'}`
288289
return {

0 commit comments

Comments
 (0)