Skip to content

Commit

Permalink
fix(layui-vue): resolve layui-vue style dir correctly (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sight-wcg committed May 27, 2022
1 parent 4d12348 commit d2eb3ee
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/core/resolvers/layui-vue.ts
@@ -1,5 +1,4 @@
import type { ComponentInfo, ComponentResolver, SideEffectsInfo } from '../../types'
import { camelCase } from '../utils'

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

function lowerCamelCase(str: string) {
return str.charAt(0).toLowerCase() + str.slice(1)
}

function getSideEffects(importName: string, options: LayuiVueResolverOptions): SideEffectsInfo | undefined {
const { importStyle = 'css' } = options
if (!importStyle)
Expand All @@ -108,7 +111,7 @@ function getSideEffects(importName: string, options: LayuiVueResolverOptions): S
if (libName !== '@layui/layui-vue')
return `${libName}/lib/index.css`

let styleDir: string | undefined = camelCase(importName.slice(3)) // LayBackTop -> backTop
let styleDir: string | undefined = lowerCamelCase(importName.slice(3)) // LayBackTop -> backTop
for (const item of matchComponents) {
if (item.pattern.test(importName)) {
styleDir = item.styleDir
Expand Down Expand Up @@ -136,7 +139,7 @@ function resolveComponent(importName: string, options: LayuiVueResolverOptions):
name = importName
libName = '@layui/layer-vue'
}
else if (importName.match(layuiRE)) {
else if (importName.match(layuiRE) && !importName.match(iconsRE)) {
name = importName
libName = '@layui/layui-vue'
}
Expand Down

0 comments on commit d2eb3ee

Please sign in to comment.