Skip to content

Commit 48b4cdb

Browse files
committed
more potato
1 parent d496f42 commit 48b4cdb

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/transformers/scss.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { readFileSync } from 'fs';
2-
import { isAbsolute, join } from 'path';
2+
import { isAbsolute, join, sep } from 'path';
33

44
import { getIncludePaths, findUp } from '../modules/utils';
55

@@ -71,14 +71,23 @@ const transformer: Transformer<Options.Sass> = async ({
7171
// For some reason, scss includes the main 'file' in the array, we don't want that
7272
// Unfortunately I didn't manage to reproduce this in the test env
7373
// More info: https://github.com/sveltejs/svelte-preprocess/issues/346
74-
const absoluteEntryPath = isAbsolute(compiled.stats.entry)
75-
? compiled.stats.entry
76-
: join(process.cwd(), compiled.stats.entry);
74+
75+
// We need to normalize the path for windows, because the sass compiler
76+
// returns a windows path in posix format __just for the entry__ (the dependency list below is fine 🤷)
77+
const normalizedEntryPath =
78+
process.platform === 'win32'
79+
? compiled.stats.entry.split('/').join(sep)
80+
: compiled.stats.entry;
81+
82+
const absoluteEntryPath = isAbsolute(normalizedEntryPath)
83+
? normalizedEntryPath
84+
: join(process.cwd(), normalizedEntryPath);
7785

7886
console.log({
79-
absoluteEntryPath,
80-
absEntry: compiled.stats.entry,
81-
absManual: join(process.cwd(), compiled.stats.entry),
87+
normalizedEntryPath,
88+
absEntry: normalizedEntryPath,
89+
isAbsEntry: isAbsolute(normalizedEntryPath),
90+
absManual: join(process.cwd(), normalizedEntryPath),
8291
included: compiled.stats.includedFiles,
8392
});
8493

0 commit comments

Comments
 (0)