Skip to content

Commit c08bee2

Browse files
Luin-Liantfu
andauthored
feat(antdv): add option to support rename package (#499)
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
1 parent ab3e003 commit c08bee2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/core/resolvers/antdv.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@ export interface AntDesignVueResolverOptions {
193193
* use commonjs build default false
194194
*/
195195
cjs?: boolean
196+
197+
/**
198+
* rename package
199+
*
200+
* @default 'ant-design-vue'
201+
*/
202+
packageName?: string
196203
}
197204

198205
function getStyleDir(compName: string): string {
@@ -220,14 +227,15 @@ function getSideEffects(compName: string, options: AntDesignVueResolverOptions):
220227
if (!importStyle)
221228
return
222229
const lib = options.cjs ? 'lib' : 'es'
230+
const packageName = options?.packageName || 'ant-design-vue'
223231

224232
if (importStyle === 'less' || importLess) {
225233
const styleDir = getStyleDir(compName)
226-
return `ant-design-vue/${lib}/${styleDir}/style`
234+
return `${packageName}/${lib}/${styleDir}/style`
227235
}
228236
else {
229237
const styleDir = getStyleDir(compName)
230-
return `ant-design-vue/${lib}/${styleDir}/style/css`
238+
return `${packageName}/${lib}/${styleDir}/style/css`
231239
}
232240
}
233241
const primitiveNames = ['Affix', 'Anchor', 'AnchorLink', 'AutoComplete', 'AutoCompleteOptGroup', 'AutoCompleteOption', 'Alert', 'Avatar', 'AvatarGroup', 'BackTop', 'Badge', 'BadgeRibbon', 'Breadcrumb', 'BreadcrumbItem', 'BreadcrumbSeparator', 'Button', 'ButtonGroup', 'Calendar', 'Card', 'CardGrid', 'CardMeta', 'Collapse', 'CollapsePanel', 'Carousel', 'Cascader', 'Checkbox', 'CheckboxGroup', 'Col', 'Comment', 'ConfigProvider', 'DatePicker', 'MonthPicker', 'WeekPicker', 'RangePicker', 'QuarterPicker', 'Descriptions', 'DescriptionsItem', 'Divider', 'Dropdown', 'DropdownButton', 'Drawer', 'Empty', 'Form', 'FormItem', 'FormItemRest', 'Grid', 'Input', 'InputGroup', 'InputPassword', 'InputSearch', 'Textarea', 'Image', 'ImagePreviewGroup', 'InputNumber', 'Layout', 'LayoutHeader', 'LayoutSider', 'LayoutFooter', 'LayoutContent', 'List', 'ListItem', 'ListItemMeta', 'Menu', 'MenuDivider', 'MenuItem', 'MenuItemGroup', 'SubMenu', 'Mentions', 'MentionsOption', 'Modal', 'Statistic', 'StatisticCountdown', 'PageHeader', 'Pagination', 'Popconfirm', 'Popover', 'Progress', 'Radio', 'RadioButton', 'RadioGroup', 'Rate', 'Result', 'Row', 'Select', 'SelectOptGroup', 'SelectOption', 'Skeleton', 'SkeletonButton', 'SkeletonAvatar', 'SkeletonInput', 'SkeletonImage', 'Slider', 'Space', 'Spin', 'Steps', 'Step', 'Switch', 'Table', 'TableColumn', 'TableColumnGroup', 'TableSummary', 'TableSummaryRow', 'TableSummaryCell', 'Transfer', 'Tree', 'TreeNode', 'DirectoryTree', 'TreeSelect', 'TreeSelectNode', 'Tabs', 'TabPane', 'Tag', 'CheckableTag', 'TimePicker', 'TimeRangePicker', 'Timeline', 'TimelineItem', 'Tooltip', 'Typography', 'TypographyLink', 'TypographyParagraph', 'TypographyText', 'TypographyTitle', 'Upload', 'UploadDragger', 'LocaleProvider']
@@ -269,8 +277,8 @@ export function AntDesignVueResolver(options: AntDesignVueResolverOptions = {
269277

270278
if (isAntdv(name) && !options?.exclude?.includes(name)) {
271279
const importName = name.slice(1)
272-
const { cjs = false } = options
273-
const path = `ant-design-vue/${cjs ? 'lib' : 'es'}`
280+
const { cjs = false, packageName = 'ant-design-vue' } = options
281+
const path = `${packageName}/${cjs ? 'lib' : 'es'}`
274282
return {
275283
name: importName,
276284
from: path,

0 commit comments

Comments
 (0)