fix(module): handle tailwindMerge config from app.config

This commit is contained in:
Benjamin Canac
2023-12-15 14:55:28 +01:00
parent 23770d8cf0
commit fd95a3f646
27 changed files with 57 additions and 55 deletions

View File

@@ -1,19 +1,21 @@
import { defu, createDefu } from 'defu'
import { extendTailwindMerge } from 'tailwind-merge'
import type { Strategy } from '../types'
// @ts-ignore
import appConfig from '#build/app.config'
const customTwMerge = extendTailwindMerge<string, string>({
export const twMerge = extendTailwindMerge<string, string>(defu({
extend: {
classGroups: {
icons: [(classPart: string) => /^i-/.test(classPart)]
}
}
})
}, appConfig.ui?.tailwindMerge))
const defuTwMerge = createDefu((obj, key, value, namespace) => {
if (namespace !== 'default' && !namespace.startsWith('default.') && typeof obj[key] === 'string' && typeof value === 'string' && obj[key] && value) {
// @ts-ignore
obj[key] = customTwMerge(obj[key], value)
obj[key] = twMerge(obj[key], value)
return true
}
})