generated from nei1ee/starter-ts
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathuni-ui.ts
31 lines (28 loc) · 833 Bytes
/
uni-ui.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import type { FilterPattern } from '@rollup/pluginutils'
import type { ComponentResolver } from '../types'
import { isExclude, kebabCase } from '../utils'
export interface UniUIResolverOptions {
/**
* RegExp or string to match component names that will NOT be imported
*/
exclude?: FilterPattern
}
export function UniUIResolver(
options: UniUIResolverOptions = {},
): ComponentResolver {
return {
type: 'component',
resolve: (name: string) => {
// Compatible with @uni-helper/vite-plugin-uni-layouts
if (isExclude(name, options.exclude) || name === 'UniLayout')
return
if (name.match(/^Uni[A-Z]/)) {
const partialName = kebabCase(name)
return {
name,
from: `@dcloudio/uni-ui/lib/${partialName}/${partialName}.vue`,
}
}
},
}
}