Skip to content

Commit 329252a

Browse files
committed
feat(varlet-ui): support vue2 version
1 parent e477b4a commit 329252a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/core/resolvers/varlet-ui.ts

+14-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import type { ComponentResolveResult, ComponentResolver } from '../../types'
22
import { kebabCase } from '../utils'
33

44
export interface VarletUIResolverOptions {
5+
/**
6+
* support vue version
7+
* vue3 use @varlet/ui, vue2 use @varlet-vue2/ui
8+
*
9+
* @default 'vue3'
10+
*/
11+
version?: 'vue3' | 'vue2'
512
/**
613
* import style along with components
714
*
@@ -32,19 +39,21 @@ export function getResolved(name: string, options: VarletUIResolverOptions): Com
3239
importStyle = 'css',
3340
importCss = true,
3441
importLess,
42+
version = 'vue3',
3543
} = options
3644

45+
const path = version === 'vue2' ? '@varlet-vue2/ui' : '@varlet/ui'
3746
const sideEffects = []
3847

3948
if (importStyle || importCss) {
4049
if (importStyle === 'less' || importLess)
41-
sideEffects.push(`@varlet/ui/es/${kebabCase(name)}/style/less.js`)
50+
sideEffects.push(`${path}/es/${kebabCase(name)}/style/less.js`)
4251
else
43-
sideEffects.push(`@varlet/ui/es/${kebabCase(name)}/style`)
52+
sideEffects.push(`${path}/es/${kebabCase(name)}/style`)
4453
}
4554

4655
return {
47-
path: '@varlet/ui',
56+
path,
4857
importName: `_${name}Component`,
4958
sideEffects,
5059
}
@@ -53,7 +62,8 @@ export function getResolved(name: string, options: VarletUIResolverOptions): Com
5362
/**
5463
* Resolver for VarletUI
5564
*
56-
* @link https://github.com/haoziqaq/varlet
65+
* @link https://github.com/varletjs/varlet
66+
* @link https://github.com/varletjs/varlet-vue2
5767
*/
5868
export function VarletUIResolver(options: VarletUIResolverOptions = {}): ComponentResolver[] {
5969
return [

0 commit comments

Comments
 (0)