|
8 | 8 |
|
9 | 9 | import { RawSourceMap } from '@ampproject/remapping';
|
10 | 10 | import MagicString from 'magic-string';
|
11 |
| -import { readFileSync, readdirSync } from 'node:fs'; |
| 11 | +import { readFileSync, readdirSync, statSync } from 'node:fs'; |
12 | 12 | import { basename, dirname, extname, join, relative } from 'node:path';
|
13 | 13 | import { fileURLToPath, pathToFileURL } from 'node:url';
|
14 | 14 | import type { CanonicalizeContext, Importer, ImporterResult, Syntax } from 'sass';
|
@@ -235,17 +235,28 @@ export class RelativeUrlRebasingImporter extends UrlRebasingImporter {
|
235 | 235 | foundImports = [];
|
236 | 236 | cachedEntries = { files: new Set<string>(), directories: new Set<string>() };
|
237 | 237 | 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 | + |
239 | 250 | if (isDirectory) {
|
240 | 251 | cachedEntries.directories.add(entry.name);
|
241 |
| - } |
242 | 252 |
|
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 | + } |
246 | 257 | }
|
247 | 258 |
|
248 |
| - if (!entry.isFile()) { |
| 259 | + if (!isFile) { |
249 | 260 | continue;
|
250 | 261 | }
|
251 | 262 |
|
|
0 commit comments