Skip to content

Commit

Permalink
fix: 🐛 splitVariantGroups does not handle all edge-cases
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderniebuhr committed Feb 28, 2022
1 parent e96e8e5 commit 492442a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ const styles: {
}

function splitVariantGroups(content: string) {
return content.replace(
/([\w!][\w/:-]*?):\(([\s\w/-]*)\)/g,
(_, groupOne: string, groupTwo: string) =>
groupTwo
.split(/\s/g)
.map((cssClass) => `${groupOne}:${cssClass}`)
.join(' ')
return content.replace(/(\w+):\(([\s\w/<:!-]+)\)/g, (_, groupOne: string, groupTwo: string) =>
groupTwo
.split(/\s/g)
.map((cssClass) => `${groupOne}:${cssClass}`)
.join(' ')
)
}

Expand Down Expand Up @@ -123,6 +121,7 @@ function extractStyles(): PreprocessorGroup {
return {
async markup({ content, filename }): Promise<Processed> {
if (!filename) return { code: content }
content = splitVariantGroups(content)
if (initialFileName.length === 0) initialFileName = filename
content = addStyleTag(content)
content = content.replace(/global:/gi, '')
Expand Down

0 comments on commit 492442a

Please sign in to comment.