Skip to content

Commit

Permalink
Improve support for purging Haml even more
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Apr 30, 2020
1 parent cdef9c8 commit 9032ff3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion __tests__/fixtures/purge-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@
.flow-root
.text-green-700.bg-green-100
.text-left= content
%samp= output
%samp.font-mono{:data-foo => "bar"}= output
.col-span-4[aria-hidden=true]
.tracking-tight#headline
4 changes: 4 additions & 0 deletions __tests__/purgeUnusedStyles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ function assertPurged(result) {
expect(result.css).toContain('.text-green-700')
expect(result.css).toContain('.bg-green-100')
expect(result.css).toContain('.text-left')
expect(result.css).toContain('.font-mono')
expect(result.css).toContain('.col-span-4')
expect(result.css).toContain('.tracking-tight')
expect(result.css).toContain('.tracking-tight')
}

test('purges unused classes', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/purgeUnusedStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function purgeUnusedUtilities(config) {
const broadMatches = content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || []

// Capture classes within other delimiters like .block(class="w-1/2") in Pug
const innerMatches = content.match(/[^<>"'`\s.()=%]*[^<>"'`\s.()=%:]/g) || []
const innerMatches = content.match(/[^<>"'`\s.(){}\[\]#=%]*[^<>"'`\s.(){}\[\]#=%:]/g) || []

return broadMatches.concat(innerMatches)
},
Expand Down

0 comments on commit 9032ff3

Please sign in to comment.