Skip to content

Commit

Permalink
fix tailwind css regex mismatch (#3221)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinglouie authored Feb 5, 2025
1 parent 6012bf1 commit 47a4848
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions resources/js/build/wordpress.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,28 @@ export function wordpressThemeJson({
fs.readFileSync(path.resolve('./theme.json'), 'utf8')
)

const themeMatch = cssContent.match(/@(?:layer\s+)?theme\s*{([^}]*)}/s)
if (!themeMatch) {
const themeContent = (() => {
const match = cssContent.match(/@(?:layer\s+)?theme\s*{/s)

if (!match[0]) {
return null
}
const startIndex = match.index + match[0].length;
let braceCount = 1;
for (let i = startIndex; i < cssContent.length; i++) {
if (cssContent[i] === "{") braceCount++;
if (cssContent[i] === "}") braceCount--;
if (braceCount === 0) {
return cssContent.substring(startIndex, i );
}
}
return null
})()

if (!themeContent) {
return;
}

const themeContent = themeMatch[1]

if (!themeContent.trim().startsWith(':root')) {
return;
}
Expand Down

0 comments on commit 47a4848

Please # to comment.