Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 18 additions & 0 deletions src/core/resolvers/_utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export function isExclude(name: string, exclude?: string | RegExp | (string | RegExp)[] | undefined): boolean {
if (!exclude)
return false

if (typeof exclude === 'string')
return name === exclude

if (exclude instanceof RegExp)
return !!name.match(exclude)

if (Array.isArray(exclude)) {
for (const item of exclude) {
if (name === item || name.match(item))
return true
}
}
return false
}
9 changes: 8 additions & 1 deletion src/core/resolvers/arco.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Debug from 'debug'
import type { ComponentInfo, ComponentResolver } from '../../types'
import { kebabCase, pascalCase } from '../utils'
import { isExclude } from './_utils'

const debug = Debug('unplugin-vue-components:resolvers:arco')

Expand Down Expand Up @@ -168,6 +169,12 @@ export type AllowResolveIconOption = true | { enable: true; iconPrefix?: string
export type ResolveIconsOption = DisallowResolveIconOption | AllowResolveIconOption

export interface ArcoResolverOptions {
/**
* exclude components that do not require automatic import
*
* @default []
*/
exclude?: string | RegExp | (string | RegExp)[]
/**
* import style css or less with components
*
Expand Down Expand Up @@ -217,7 +224,7 @@ export function ArcoResolver(
}
}
}
if (name.match(/^A[A-Z]/)) {
if (name.match(/^A[A-Z]/) && !isExclude(name, options.exclude)) {
const importStyle = options.importStyle ?? 'css'

const importName = name.slice(1)
Expand Down
2 changes: 1 addition & 1 deletion src/core/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parse } from 'node:path'
import {minimatch} from 'minimatch'
import { minimatch } from 'minimatch'
import resolve from 'resolve'
import { slash, toArray } from '@antfu/utils'
import {
Expand Down