Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): ensure proper resolution of linke…
Browse files Browse the repository at this point in the history
…d 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 e22d677)
  • Loading branch information
alan-agius4 committed Mar 25, 2024
1 parent 27dd8f2 commit 59fba38
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -235,17 +235,28 @@ export class RelativeUrlRebasingImporter extends UrlRebasingImporter {
foundImports = [];
cachedEntries = { files: new Set<string>(), directories: new Set<string>() };
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;
}

Expand Down

0 comments on commit 59fba38

Please sign in to comment.