Skip to content

Commit b0ac3c5

Browse files
committed
Support purging Pug templates a bit better
1 parent 4c3e97c commit b0ac3c5

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

__tests__/fixtures/purge-example.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@
1313

1414
<!-- Custom classes with really weird characters -->
1515
<div class="min-h-(screen-4) bg-black! font-%#$@ w-(1/2+8)"></div>
16+
17+
<!-- Pug -->
18+
span.inline-grid.grid-cols-3
19+
.col-span-2
20+
Hello
21+
.col-span-1.text-center
22+
World!

__tests__/fixtures/tailwind-output-purged.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,10 @@ video {
594594
display: block;
595595
}
596596

597+
.inline-grid {
598+
display: inline-grid;
599+
}
600+
597601
.font-\%\#\$\@ {
598602
font-family: Comic Sans;
599603
}
@@ -602,6 +606,10 @@ video {
602606
height: 100vh;
603607
}
604608

609+
.text-center {
610+
text-align: center;
611+
}
612+
605613
.w-\(1\/2\+8\) {
606614
width: calc(50% + 2rem);
607615
}
@@ -610,6 +618,18 @@ video {
610618
width: 50%;
611619
}
612620

621+
.grid-cols-3 {
622+
grid-template-columns: repeat(3, minmax(0, 1fr));
623+
}
624+
625+
.col-span-1 {
626+
grid-column: span 1 / span 1;
627+
}
628+
629+
.col-span-2 {
630+
grid-column: span 2 / span 2;
631+
}
632+
613633
.example {
614634
font-weight: 700;
615635
color: #f56565;

src/lib/purgeUnusedUtilities.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ export default function purgeUnusedUtilities(config) {
5050
},
5151
purgecss({
5252
content: Array.isArray(config.purge) ? config.purge : config.purge.paths,
53-
defaultExtractor: content => content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || [],
53+
defaultExtractor: content => {
54+
return (
55+
content
56+
.match(/[^<>"'`\s]*[^<>"'`\s:]/g)
57+
.concat(content.match(/[^<>"'`\s.]*[^<>"'`\s:.]/g)) || []
58+
)
59+
},
5460
}),
5561
])
5662
}

0 commit comments

Comments
 (0)