From 8c7fb84e581ecaac85cd8912c30905899a967e4c Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Sun, 16 Aug 2020 14:03:37 +0200 Subject: [PATCH] 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. --- src/flagged/applyComplexClasses.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/flagged/applyComplexClasses.js b/src/flagged/applyComplexClasses.js index 9b1d7e8f7..17e335a27 100644 --- a/src/flagged/applyComplexClasses.js +++ b/src/flagged/applyComplexClasses.js @@ -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)