bail out of the applyComplexClasses when it is not needed

There is no need in re-compiling tailwind or building expensive lookupt
tables when it turns out that we don't even need it.

We have a small overhead by walking the tree to check if `@apply`
exists. However this outweighs the slowness of re-generating tailwind +
expensive lookup tables.
This commit is contained in:
Robin Malfait 2020-08-16 14:03:37 +02:00 • committed by Adam Wathan
parent 4b15b90f21
commit 8c7fb84e58

View file

@ -236,6 +236,11 @@ function processApplyAtRules(css, lookupTree, config) {
export default function applyComplexClasses(config, getProcessedPlugins) {
return function(css) {
// We can stop already when we don't have any @apply rules. Vue users: you're welcome!
if (!hasAtRule(css, 'apply')) {
return css
}
// Tree already contains @tailwind rules, don't prepend default Tailwind tree
if (hasAtRule(css, 'tailwind')) {
return processApplyAtRules(css, css, config)