Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit 798d394

Browse files
committed
feat: support caching options as object
1 parent 750bcc2 commit 798d394

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/lib/setupContext.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ function resolveConfigPath(pathOrConfig) {
146146
}
147147

148148
let configPathCache = new LRU({ maxSize: 100 })
149+
let lastTailwindConfigHash = null
149150

150151
// Get the config object based on a path
151152
function getTailwindConfig(configOrPath) {
@@ -174,7 +175,7 @@ function getTailwindConfig(configOrPath) {
174175
configOrPath.config === undefined ? configOrPath : configOrPath.config
175176
)
176177

177-
return [newConfig, null, hash(newConfig)]
178+
return [newConfig, null, newConfig.hash || hash(newConfig)]
178179
}
179180

180181
let fileModifiedMap = new Map()
@@ -656,8 +657,10 @@ function setupContext(configOrPath) {
656657
if (!contextDependenciesChanged) {
657658
// If this file already has a context in the cache and we don't need to
658659
// reset the context, return the cached context.
659-
if (isConfigFile && contextMap.has(sourcePath)) {
660-
return contextMap.get(sourcePath)
660+
if (contextMap.has(sourcePath)) {
661+
if (isConfigFile || (lastTailwindConfigHash && tailwindConfigHash === lastTailwindConfigHash)) {
662+
return contextMap.get(sourcePath)
663+
}
661664
}
662665

663666
// If the config used already exists in the cache, return that.
@@ -669,6 +672,8 @@ function setupContext(configOrPath) {
669672
}
670673
}
671674

675+
lastTailwindConfigHash = tailwindConfigHash
676+
672677
// If this source is in the context map, get the old context.
673678
// Remove this source from the context sources for the old context,
674679
// and clean up that context if no one else is using it. This can be

0 commit comments

Comments
 (0)