Allow users to block generation of certain utilities (#9812)
* Add blocklist tests * Build initial implementation of blocklist * wip * wip * wip * Update changelog
This commit is contained in:
parent
4ccc0fa12a
commit
602101d030
4 changed files with 140 additions and 1 deletions
|
|
@ -1165,7 +1165,8 @@ export function createContext(tailwindConfig, changedContent = [], root = postcs
|
|||
candidateRuleCache: new Map(),
|
||||
classCache: new Map(),
|
||||
applyClassCache: new Map(),
|
||||
notClassCache: new Set(),
|
||||
// Seed the not class cache with the blocklist (which is only strings)
|
||||
notClassCache: new Set(tailwindConfig.blocklist ?? []),
|
||||
postCssNodeCache: new Map(),
|
||||
candidateRuleMap: new Map(),
|
||||
tailwindConfig,
|
||||
|
|
|
|||
|
|
@ -150,6 +150,24 @@ export function normalizeConfig(config) {
|
|||
return []
|
||||
})()
|
||||
|
||||
// Normalize the `blocklist`
|
||||
config.blocklist = (() => {
|
||||
let { blocklist } = config
|
||||
|
||||
if (Array.isArray(blocklist)) {
|
||||
if (blocklist.every((item) => typeof item === 'string')) {
|
||||
return blocklist
|
||||
}
|
||||
|
||||
log.warn('blocklist-invalid', [
|
||||
'The `blocklist` option must be an array of strings.',
|
||||
'https://tailwindcss.com/docs/content-configuration#discarding-classes',
|
||||
])
|
||||
}
|
||||
|
||||
return []
|
||||
})()
|
||||
|
||||
// Normalize prefix option
|
||||
if (typeof config.prefix === 'function') {
|
||||
log.warn('prefix-function', [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue