11import { readFileSync } from 'fs' ;
2- import { isAbsolute , join } from 'path' ;
2+ import path from 'path' ;
33
44import { getIncludePaths , findUp } from '../modules/utils' ;
55
@@ -19,7 +19,7 @@ const tildeImporter: LegacySyncImporter = (url, prev) => {
1919 prev = decodeURIComponent ( prev ) ;
2020 }
2121
22- const modulePath = join ( 'node_modules' , ...url . slice ( 1 ) . split ( / [ \\ / ] / g) ) ;
22+ const modulePath = path . join ( 'node_modules' , ...url . slice ( 1 ) . split ( / [ \\ / ] / g) ) ;
2323
2424 const foundPath = findUp ( { what : modulePath , from : prev } ) ;
2525
@@ -68,12 +68,20 @@ const transformer: Transformer<Options.Sass> = async ({
6868
6969 const compiled = renderSync ( sassOptions ) ;
7070
71+ // We need to normalize the path for windows, because the sass compiler
72+ // returns a windows path in posix format __just for the entry__ (the dependency list below is fine 🤷)
73+ // More info: https://github.com/sveltejs/svelte-preprocess/issues/619
74+ const normalizedEntryPath =
75+ process . platform === 'win32'
76+ ? compiled . stats . entry . split ( '/' ) . join ( path . win32 . sep )
77+ : compiled . stats . entry ;
78+
7179 // For some reason, scss includes the main 'file' in the array, we don't want that
7280 // Unfortunately I didn't manage to reproduce this in the test env
7381 // 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 ) ;
82+ const absoluteEntryPath = path . isAbsolute ( normalizedEntryPath )
83+ ? normalizedEntryPath
84+ : path . join ( process . cwd ( ) , normalizedEntryPath ) ;
7785
7886 const processed = {
7987 code : compiled . css . toString ( ) ,
0 commit comments