Skip to content

Commit

Permalink
Support purging Pug templates a bit better
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Apr 28, 2020
1 parent 4c3e97c commit b0ac3c5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
7 changes: 7 additions & 0 deletions __tests__/fixtures/purge-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@

<!-- Custom classes with really weird characters -->
<div class="min-h-(screen-4) bg-black! font-%#$@ w-(1/2+8)"></div>

<!-- Pug -->
span.inline-grid.grid-cols-3
.col-span-2
Hello
.col-span-1.text-center
World!
20 changes: 20 additions & 0 deletions __tests__/fixtures/tailwind-output-purged.css
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,10 @@ video {
display: block;
}

.inline-grid {
display: inline-grid;
}

.font-\%\#\$\@ {
font-family: Comic Sans;
}
Expand All @@ -602,6 +606,10 @@ video {
height: 100vh;
}

.text-center {
text-align: center;
}

.w-\(1\/2\+8\) {
width: calc(50% + 2rem);
}
Expand All @@ -610,6 +618,18 @@ video {
width: 50%;
}

.grid-cols-3 {
grid-template-columns: repeat(3, minmax(0, 1fr));
}

.col-span-1 {
grid-column: span 1 / span 1;
}

.col-span-2 {
grid-column: span 2 / span 2;
}

.example {
font-weight: 700;
color: #f56565;
Expand Down
8 changes: 7 additions & 1 deletion src/lib/purgeUnusedUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ export default function purgeUnusedUtilities(config) {
},
purgecss({
content: Array.isArray(config.purge) ? config.purge : config.purge.paths,
defaultExtractor: content => content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || [],
defaultExtractor: content => {
return (
content
.match(/[^<>"'`\s]*[^<>"'`\s:]/g)
.concat(content.match(/[^<>"'`\s.]*[^<>"'`\s:.]/g)) || []
)
},
}),
])
}

0 comments on commit b0ac3c5

Please sign in to comment.