From a5e8ea6aa82affacba66ce9a039a40642aefaba3 Mon Sep 17 00:00:00 2001 From: hugocasa Date: Wed, 11 Nov 2026 13:59:50 +0100 Subject: [PATCH] fix: find class lists nested in template literals Co-Authored-By: Claude Opus 5.5 --- cli/src/commands/app/bundle.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cli/src/commands/app/bundle.ts b/cli/src/commands/app/bundle.ts index 024e0630a5..fbe93ad75f 100644 --- a/cli/src/commands/app/bundle.ts +++ b/cli/src/commands/app/bundle.ts @@ -274,9 +274,10 @@ function collectTailwindCandidates(dirs: string[]): string[] { }; // Class lists live in string literals, whose content is split on whitespace // only, so arbitrary values keep their quotes, `=` and `>` - // (`data-[state=open]:…`, `content-['x']`, `[&>svg]:hidden`). - for (const m of text.matchAll(/"([^"\n]*)"|'([^'\n]*)'|`([^`]*)`/g)) { - (m[1] ?? m[2] ?? m[3]).split(/\s+/).forEach(add); + // (`data-[state=open]:…`, `content-['x']`, `[&>svg]:hidden`). Each quote kind is + // matched on its own so a `class="…"` inside a template literal is still found. + for (const re of [/"([^"\n]*)"/g, /'([^'\n]*)'/g, /`([^`]*)`/g]) { + for (const m of text.matchAll(re)) m[1].split(/\s+/).forEach(add); } // Classes outside literals: Svelte directives, markup. text.split(/[\s"'`{}<>;=]+/).forEach(add);