@@ -25,6 +25,7 @@ const { isBuffer } = require('util')
25
25
let contextMap = sharedState . contextMap
26
26
let configContextMap = sharedState . configContextMap
27
27
let contextSourcesMap = sharedState . contextSourcesMap
28
+ let configHashMap = sharedState . configHashMap
28
29
let env = sharedState . env
29
30
30
31
// Earmarks a directory for our touch files.
@@ -629,6 +630,8 @@ function setupContext(configOrPath) {
629
630
let [ tailwindConfig , userConfigPath , tailwindConfigHash ] = getTailwindConfig ( configOrPath )
630
631
let isConfigFile = userConfigPath !== null
631
632
633
+ const { _cacheGroup = 'default' , _hash } = tailwindConfig
634
+
632
635
let contextDependencies = new Set ( )
633
636
634
637
// If there are no @tailwind rules, we don't consider this CSS file or it's dependencies
@@ -656,8 +659,13 @@ function setupContext(configOrPath) {
656
659
if ( ! contextDependenciesChanged ) {
657
660
// If this file already has a context in the cache and we don't need to
658
661
// 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
+ }
661
669
}
662
670
663
671
// If the config used already exists in the cache, return that.
@@ -669,6 +677,10 @@ function setupContext(configOrPath) {
669
677
}
670
678
}
671
679
680
+ if ( _hash ) {
681
+ configHashMap . set ( _cacheGroup , _hash )
682
+ }
683
+
672
684
// If this source is in the context map, get the old context.
673
685
// Remove this source from the context sources for the old context,
674
686
// and clean up that context if no one else is using it. This can be
0 commit comments