diff --git a/src/colors.ts b/src/colors.ts index a85e2e1e..efccd36a 100644 --- a/src/colors.ts +++ b/src/colors.ts @@ -117,7 +117,7 @@ export const excludeColors = (colors: object) => Object.keys(omit(colors, colors export const generateSafelist = (colors: string[]) => ['avatar', 'badge', 'button', 'input', 'notification'].flatMap(component => safelistByComponent[component](colorsAsRegex(colors))) -export const customSafelistExtractor = (prefix, content: string) => { +export const customSafelistExtractor = (prefix, content: string, colors: string[]) => { const classes = [] const regex = /<(\w+)\s+[^>:]*color=["']([^"']+)["'][^>]*>/gs const matches = [...content.matchAll(regex)] @@ -125,7 +125,7 @@ export const customSafelistExtractor = (prefix, content: string) => { for (const match of matches) { const [, component, color] = match - if (colorsToExclude.includes(color)) { + if (!colors.includes(color)) { continue } diff --git a/src/module.ts b/src/module.ts index 8405e5d9..aa0cc298 100644 --- a/src/module.ts +++ b/src/module.ts @@ -152,7 +152,7 @@ export default defineNuxtModule({ vue: (content) => { return [ ...defaultExtractor(content), - ...customSafelistExtractor(options.prefix, content) + ...customSafelistExtractor(options.prefix, content, nuxt.options.appConfig.ui.colors) ] } }