From 88c1930845d26c66c2fbd32f99f52dbd23244341 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Tue, 13 Jun 2023 15:53:02 +0200 Subject: [PATCH] fix(module): transform `vue` files to detect multi-line components --- src/colors.ts | 2 +- src/module.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/colors.ts b/src/colors.ts index f14cdec3..98a6f0db 100644 --- a/src/colors.ts +++ b/src/colors.ts @@ -141,7 +141,7 @@ export const generateSafelist = (colors: string[]) => { export const customSafelistExtractor = (prefix, content: string, colors: string[]) => { const classes = [] const regex = /<(\w+)\s+[^>:]*color=["']([^"']+)["'][^>]*>/gs - const matches = [...content.matchAll(regex)] + const matches = content.matchAll(regex) for (const match of matches) { const [, component, color] = match diff --git a/src/module.ts b/src/module.ts index aa0cc298..8ebfc5f0 100644 --- a/src/module.ts +++ b/src/module.ts @@ -148,6 +148,11 @@ export default defineNuxtModule({ resolve(runtimeDir, 'components/**/*.{vue,mjs,ts}'), resolve(runtimeDir, '*.{mjs,js,ts}') ], + transform: { + vue: (content) => { + return content.replaceAll(/(?:\r\n|\r|\n)/g, ' ') + } + }, extract: { vue: (content) => { return [