Skip to content

Commit 627e8af

Browse files
committed
fix(varlet): import style options changes
1 parent cedadb8 commit 627e8af

File tree

1 file changed

+31
-19
lines changed

1 file changed

+31
-19
lines changed

src/resolvers/varlet-ui.ts

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@ import { kebabCase } from '../utils'
33

44
export interface VarletUIResolverOptions {
55
/**
6-
* import css along with components
6+
* import style along with components
77
*
8-
* @default true
8+
* @default 'css'
9+
*/
10+
importStyle?: boolean | 'css' | 'less'
11+
12+
/**
13+
* @deprecated use `importStyle: 'css'` instead
914
*/
1015
importCss?: boolean
1116
/**
12-
* import less along with components
13-
*
14-
* @default false
17+
* @deprecated use `importStyle: 'less'` instead
1518
*/
1619
importLess?: boolean
1720
}
@@ -21,21 +24,30 @@ export interface VarletUIResolverOptions {
2124
*
2225
* @link https://github.com/haoziqaq/varlet
2326
*/
24-
export const VarletUIResolver = (options: VarletUIResolverOptions = {}): ComponentResolver => (name: string) => {
25-
const {
26-
importCss = true,
27-
importLess,
28-
} = options
29-
if (name.startsWith('Var')) {
30-
const partialName = name.slice(3)
31-
const sideEffects = []
32-
importCss && sideEffects.push(`@varlet/ui/es/${kebabCase(partialName)}/style`)
33-
importLess && sideEffects.push(`@varlet/ui/es/${kebabCase(partialName)}/style/less.js`)
27+
export function VarletUIResolver(options: VarletUIResolverOptions = {}): ComponentResolver {
28+
return (name: string) => {
29+
const {
30+
importStyle = 'css',
31+
importCss = true,
32+
importLess,
33+
} = options
34+
35+
if (name.startsWith('Var')) {
36+
const partialName = name.slice(3)
37+
const sideEffects = []
38+
39+
if (importStyle || importCss) {
40+
if (importStyle === 'less' || importLess)
41+
sideEffects.push(`@varlet/ui/es/${kebabCase(partialName)}/style/less.js`)
42+
else
43+
sideEffects.push(`@varlet/ui/es/${kebabCase(partialName)}/style`)
44+
}
3445

35-
return {
36-
importName: `_${partialName}Component`,
37-
path: '@varlet/ui',
38-
sideEffects,
46+
return {
47+
importName: `_${partialName}Component`,
48+
path: '@varlet/ui',
49+
sideEffects,
50+
}
3951
}
4052
}
4153
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy