@@ -25,6 +25,7 @@ const { isBuffer } = require('util')
2525let contextMap = sharedState . contextMap
2626let configContextMap = sharedState . configContextMap
2727let contextSourcesMap = sharedState . contextSourcesMap
28+ let configHashMap = sharedState . configHashMap
2829let env = sharedState . env
2930
3031// Earmarks a directory for our touch files.
@@ -629,6 +630,8 @@ function setupContext(configOrPath) {
629630 let [ tailwindConfig , userConfigPath , tailwindConfigHash ] = getTailwindConfig ( configOrPath )
630631 let isConfigFile = userConfigPath !== null
631632
633+ const { _cacheGroup = 'default' , _hash } = tailwindConfig
634+
632635 let contextDependencies = new Set ( )
633636
634637 // If there are no @tailwind rules, we don't consider this CSS file or it's dependencies
@@ -656,8 +659,13 @@ function setupContext(configOrPath) {
656659 if ( ! contextDependenciesChanged ) {
657660 // If this file already has a context in the cache and we don't need to
658661 // reset the context, return the cached context.
659- if ( isConfigFile && contextMap . has ( sourcePath ) ) {
660- return contextMap . get ( sourcePath )
662+ if ( contextMap . has ( sourcePath ) ) {
663+ if (
664+ isConfigFile ||
665+ ( _hash && configHashMap . has ( _cacheGroup ) && _hash === configHashMap . get ( _cacheGroup ) )
666+ ) {
667+ return contextMap . get ( sourcePath )
668+ }
661669 }
662670
663671 // If the config used already exists in the cache, return that.
@@ -669,6 +677,10 @@ function setupContext(configOrPath) {
669677 }
670678 }
671679
680+ if ( _hash ) {
681+ configHashMap . set ( _cacheGroup , _hash )
682+ }
683+
672684 // If this source is in the context map, get the old context.
673685 // Remove this source from the context sources for the old context,
674686 // and clean up that context if no one else is using it. This can be
0 commit comments