diff --git a/src/transformers/scss.ts b/src/transformers/scss.ts index 5bea83cc..05fcdfbb 100644 --- a/src/transformers/scss.ts +++ b/src/transformers/scss.ts @@ -1,5 +1,5 @@ import { readFileSync } from 'fs'; -import { isAbsolute, join } from 'path'; +import { isAbsolute, join, sep } from 'path'; import { getIncludePaths, findUp } from '../modules/utils'; @@ -71,14 +71,23 @@ const transformer: Transformer = async ({ // For some reason, scss includes the main 'file' in the array, we don't want that // Unfortunately I didn't manage to reproduce this in the test env // More info: https://github.com/sveltejs/svelte-preprocess/issues/346 - const absoluteEntryPath = isAbsolute(compiled.stats.entry) - ? compiled.stats.entry - : join(process.cwd(), compiled.stats.entry); + + // We need to normalize the path for windows, because the sass compiler + // returns a windows path in posix format __just for the entry__ (the dependency list below is fine 🤷) + const normalizedEntryPath = + process.platform === 'win32' + ? compiled.stats.entry.split('/').join(sep) + : compiled.stats.entry; + + const absoluteEntryPath = isAbsolute(normalizedEntryPath) + ? normalizedEntryPath + : join(process.cwd(), normalizedEntryPath); console.log({ - absoluteEntryPath, - absEntry: compiled.stats.entry, - absManual: join(process.cwd(), compiled.stats.entry), + normalizedEntryPath, + absEntry: normalizedEntryPath, + isAbsEntry: isAbsolute(normalizedEntryPath), + absManual: join(process.cwd(), normalizedEntryPath), included: compiled.stats.includedFiles, });