Skip to content

Commit d2eb3ee

Browse files
authored
fix(layui-vue): resolve layui-vue style dir correctly (#388)
1 parent 4d12348 commit d2eb3ee

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/core/resolvers/layui-vue.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { ComponentInfo, ComponentResolver, SideEffectsInfo } from '../../types'
2-
import { camelCase } from '../utils'
32

43
const matchComponents = [
54
{
@@ -100,6 +99,10 @@ const layerRE = /^(layer|LayLayer)$/
10099
const iconsRE = /^([A-Z][\w]+Icon|LayIcon)$/
101100
let libName = '@layui/layui-vue'
102101

102+
function lowerCamelCase(str: string) {
103+
return str.charAt(0).toLowerCase() + str.slice(1)
104+
}
105+
103106
function getSideEffects(importName: string, options: LayuiVueResolverOptions): SideEffectsInfo | undefined {
104107
const { importStyle = 'css' } = options
105108
if (!importStyle)
@@ -108,7 +111,7 @@ function getSideEffects(importName: string, options: LayuiVueResolverOptions): S
108111
if (libName !== '@layui/layui-vue')
109112
return `${libName}/lib/index.css`
110113

111-
let styleDir: string | undefined = camelCase(importName.slice(3)) // LayBackTop -> backTop
114+
let styleDir: string | undefined = lowerCamelCase(importName.slice(3)) // LayBackTop -> backTop
112115
for (const item of matchComponents) {
113116
if (item.pattern.test(importName)) {
114117
styleDir = item.styleDir
@@ -136,7 +139,7 @@ function resolveComponent(importName: string, options: LayuiVueResolverOptions):
136139
name = importName
137140
libName = '@layui/layer-vue'
138141
}
139-
else if (importName.match(layuiRE)) {
142+
else if (importName.match(layuiRE) && !importName.match(iconsRE)) {
140143
name = importName
141144
libName = '@layui/layui-vue'
142145
}

0 commit comments

Comments
 (0)