Skip to content

Conversation

@thecrypticace
Copy link
Contributor

@thecrypticace thecrypticace commented Sep 30, 2024

This PR adds support for the blocklist config option when using a JS config file in v4. You can now block certain classes from being generated at all. This is useful in cases where scanning files sees things that look like classes but are actually not used. For example, in paragraphs in a markdown file:

// tailwind.config.js
export default {
  blocklist: ['bg-red-500'],
}
<!-- index.html -->
<div class="bg-red-500 text-black/75"></div>

Output:

.text-black/75 {
  color: rgba(0, 0, 0, 0.75);
}

@thecrypticace thecrypticace marked this pull request as ready for review September 30, 2024 16:43
@thecrypticace
Copy link
Contributor Author

I'll fix the changelog conflict when we're ready to merge.

Copy link
Member

@RobinMalfait RobinMalfait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Can we add a test to make sure that @apply bg-white also doesn't work?

This is what v3 does: https://play.tailwindcss.com/ewH6tmV5q4?file=css

@thecrypticace thecrypticace force-pushed the feat/v4-blocklist-compat branch from 0ba85df to ff7eb0e Compare September 30, 2024 18:11
@thecrypticace
Copy link
Contributor Author

Good call — I fixed that case and added a test for it.

@thecrypticace
Copy link
Contributor Author

I think there's some wiggle room in the future here such that blocklist only applies to generated candidates. This is because the nature of content scanning means you're likely scanning content you can't change for the sake of Tailwind. But @apply you always write explicitly and the failure mode is always hard crash when something doesn't exist.

@thecrypticace thecrypticace merged commit 6a50e6e into next Sep 30, 2024
3 checks passed
@thecrypticace thecrypticace deleted the feat/v4-blocklist-compat branch September 30, 2024 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants