Skip to content

Commit

Permalink
fix: include cssUrl and styleIncludePaths in the CSS cache key
Browse files Browse the repository at this point in the history
Prior to this change these 2 options where not added as part of the cache key which caused the cache to be invalidated when one of these options change.

Closes #2523
  • Loading branch information
alan-agius4 committed Jan 9, 2023
1 parent b1a5711 commit 6bb7a4a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/styles/stylesheet-processor-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ interface RenderRequest {
filePath: string;
}

const CACHE_KEY_VALUES = [...browserslistData, ...styleIncludePaths, cssUrl].join(':');

async function render({ content, filePath }: RenderRequest): Promise<string> {
let key: string | undefined;
if (cacheDirectory && !content.includes('@import') && !content.includes('@use')) {
// No transitive deps, we can cache more aggressively.
key = await generateKey(content, ...browserslistData);
key = await generateKey(content, CACHE_KEY_VALUES);
const result = await readCacheEntry(cacheDirectory, key);
if (result) {
result.warnings.forEach(msg => log.warn(msg));
Expand All @@ -47,7 +49,7 @@ async function render({ content, filePath }: RenderRequest): Promise<string> {
// We cannot cache CSS re-rendering phase, because a transitive dependency via (@import) can case different CSS output.
// Example a change in a mixin or SCSS variable.
if (!key) {
key = await generateKey(renderedCss, ...browserslistData);
key = await generateKey(renderedCss, CACHE_KEY_VALUES);
}

if (cacheDirectory) {
Expand Down

0 comments on commit 6bb7a4a

Please sign in to comment.