8000 Integrate PurgeCSS directly into Tailwind by adamwathan · Pull Request #1639 · tailwindlabs/tailwindcss · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Support purging Pug templates a bit better
  • Loading branch information
adamwathan committed Apr 28, 2020
commit b0ac3c50cb714956c3094da899c163570e5f0c57
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)) || []
)
},
}),
])
}