Skip to content

Commit

Permalink
fix(eleventy-plugin-styles): fixed compile conditions on file changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Olezhka-web committed Sep 27, 2023
1 parent 9c6af5f commit 239d18d
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions packages/eleventy-plugin-styles/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join, normalize } from 'path';
import { join, normalize, resolve } from 'path';

import { isJust, pipe, tap } from '@fluss/core';
import {
Expand Down Expand Up @@ -150,22 +150,26 @@ export const styles = (
config.on('beforeWatch', (changedFiles: ReadonlyArray<string>) =>
changedFiles
.filter((relativePath) => /(sc|sa|le|c)ss$/.test(relativePath))
.map((cachedPath) =>
cache
.entries()
.filter(
([mainURL, { urls }]) =>
mainURL === cachedPath ||
urls.some((fileName) => cachedPath.endsWith(fileName)),
)
.forEach(([_originalUrl, entity]) => {
Debugger.object` Detected change relates to the ${{
file: entity.originalUrl,
imports: entity.urls,
}}. Updating memory cache...`;

cache.put(entity.sourcePath, { ...entity, isEdit: true });
}),
.map(
pipe(
(mainURL: string) => resolve(mainURL),
(mainURL: string) =>
cache
.entries()
.filter(
([cachedPath, { urls }]) =>
mainURL === cachedPath ||
urls.some((fileName) => mainURL.endsWith(fileName)),
)
.forEach(([_originalUrl, entity]) => {
Debugger.object` Detected change relates to the ${{
file: entity.originalUrl,
imports: entity.urls,
}}. Updating memory cache...`;

cache.put(entity.sourcePath, { ...entity, isEdit: true });
}),
),
),
);

Expand Down

0 comments on commit 239d18d

Please sign in to comment.