Skip to content

feat(antdv): add option to support rename package #499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/core/resolvers/antdv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ export interface AntDesignVueResolverOptions {
* use commonjs build default false
*/
cjs?: boolean

/**
* rename package
*
* @default 'ant-design-vue'
*/
packageName?: string
}

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

if (importStyle === 'less' || importLess) {
const styleDir = getStyleDir(compName)
return `ant-design-vue/${lib}/${styleDir}/style`
return `${packageName}/${lib}/${styleDir}/style`
}
else {
const styleDir = getStyleDir(compName)
return `ant-design-vue/${lib}/${styleDir}/style/css`
return `${packageName}/${lib}/${styleDir}/style/css`
}
}
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']
Expand Down Expand Up @@ -269,8 +277,8 @@ export function AntDesignVueResolver(options: AntDesignVueResolverOptions = {

if (isAntdv(name) && !options?.exclude?.includes(name)) {
const importName = name.slice(1)
const { cjs = false } = options
const path = `ant-design-vue/${cjs ? 'lib' : 'es'}`
const { cjs = false, packageName = 'ant-design-vue' } = options
const path = `${packageName}/${cjs ? 'lib' : 'es'}`
return {
name: importName,
from: path,
Expand Down