From 59fba38ec6181c8d9c7a0636fb514c4b25aaf0cd Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 25 Mar 2024 12:33:58 +0000 Subject: [PATCH] fix(@angular-devkit/build-angular): ensure proper resolution of linked SCSS files This commit addresses a bug where SCSS files within linked directories were not being resolved correctly by the Angular CLI. By implementing the necessary adjustments, linked SCSS files are now properly resolved. Closes #27353 (cherry picked from commit e22d6771da9f289577410b66d3fd8763b12113b2) --- .../src/tools/sass/rebasing-importer.ts | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/angular_devkit/build_angular/src/tools/sass/rebasing-importer.ts b/packages/angular_devkit/build_angular/src/tools/sass/rebasing-importer.ts index 0c2f33d2d52b..1a83ce76824c 100644 --- a/packages/angular_devkit/build_angular/src/tools/sass/rebasing-importer.ts +++ b/packages/angular_devkit/build_angular/src/tools/sass/rebasing-importer.ts @@ -8,7 +8,7 @@ import { RawSourceMap } from '@ampproject/remapping'; import MagicString from 'magic-string'; -import { readFileSync, readdirSync } from 'node:fs'; +import { readFileSync, readdirSync, statSync } from 'node:fs'; import { basename, dirname, extname, join, relative } from 'node:path'; import { fileURLToPath, pathToFileURL } from 'node:url'; import type { CanonicalizeContext, Importer, ImporterResult, Syntax } from 'sass'; @@ -235,17 +235,28 @@ export class RelativeUrlRebasingImporter extends UrlRebasingImporter { foundImports = []; cachedEntries = { files: new Set(), directories: new Set() }; for (const entry of entries) { - const isDirectory = entry.isDirectory(); + let isDirectory: boolean; + let isFile: boolean; + + if (entry.isSymbolicLink()) { + const stats = statSync(join(entry.path, entry.name)); + isDirectory = stats.isDirectory(); + isFile = stats.isFile(); + } else { + isDirectory = entry.isDirectory(); + isFile = entry.isFile(); + } + if (isDirectory) { cachedEntries.directories.add(entry.name); - } - // Record if the name should be checked as a directory with an index file - if (checkDirectory && !hasStyleExtension && entry.name === filename && isDirectory) { - hasPotentialIndex = true; + // Record if the name should be checked as a directory with an index file + if (checkDirectory && !hasStyleExtension && entry.name === filename) { + hasPotentialIndex = true; + } } - if (!entry.isFile()) { + if (!isFile) { continue; }