Skip to content

Commit e22d677

Browse files
committed
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
1 parent c71e954 commit e22d677

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

packages/angular_devkit/build_angular/src/tools/sass/rebasing-importer.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import { RawSourceMap } from '@ampproject/remapping';
1010
import MagicString from 'magic-string';
11-
import { readFileSync, readdirSync } from 'node:fs';
11+
import { readFileSync, readdirSync, statSync } from 'node:fs';
1212
import { basename, dirname, extname, join, relative } from 'node:path';
1313
import { fileURLToPath, pathToFileURL } from 'node:url';
1414
import type { CanonicalizeContext, Importer, ImporterResult, Syntax } from 'sass';
@@ -235,17 +235,28 @@ export class RelativeUrlRebasingImporter extends UrlRebasingImporter {
235235
foundImports = [];
236236
cachedEntries = { files: new Set<string>(), directories: new Set<string>() };
237237
for (const entry of entries) {
238-
const isDirectory = entry.isDirectory();
238+
let isDirectory: boolean;
239+
let isFile: boolean;
240+
241+
if (entry.isSymbolicLink()) {
242+
const stats = statSync(join(entry.path, entry.name));
243+
isDirectory = stats.isDirectory();
244+
isFile = stats.isFile();
245+
} else {
246+
isDirectory = entry.isDirectory();
247+
isFile = entry.isFile();
248+
}
249+
239250
if (isDirectory) {
240251
cachedEntries.directories.add(entry.name);
241-
}
242252

243-
// Record if the name should be checked as a directory with an index file
244-
if (checkDirectory && !hasStyleExtension && entry.name === filename && isDirectory) {
245-
hasPotentialIndex = true;
253+
// Record if the name should be checked as a directory with an index file
254+
if (checkDirectory && !hasStyleExtension && entry.name === filename) {
255+
hasPotentialIndex = true;
256+
}
246257
}
247258

248-
if (!entry.isFile()) {
259+
if (!isFile) {
249260
continue;
250261
}
251262

0 commit comments

Comments
 (0)