1
1
import { readFileSync } from 'fs' ;
2
- import { isAbsolute , join } from 'path' ;
2
+ import path from 'path' ;
3
3
4
4
import { getIncludePaths , findUp } from '../modules/utils' ;
5
5
@@ -19,7 +19,7 @@ const tildeImporter: LegacySyncImporter = (url, prev) => {
19
19
prev = decodeURIComponent ( prev ) ;
20
20
}
21
21
22
- const modulePath = join ( 'node_modules' , ...url . slice ( 1 ) . split ( / [ \\ / ] / g) ) ;
22
+ const modulePath = path . join ( 'node_modules' , ...url . slice ( 1 ) . split ( / [ \\ / ] / g) ) ;
23
23
24
24
const foundPath = findUp ( { what : modulePath , from : prev } ) ;
25
25
@@ -68,12 +68,20 @@ const transformer: Transformer<Options.Sass> = async ({
68
68
69
69
const compiled = renderSync ( sassOptions ) ;
70
70
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
+
71
79
// For some reason, scss includes the main 'file' in the array, we don't want that
72
80
// Unfortunately I didn't manage to reproduce this in the test env
73
81
// 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 ) ;
77
85
78
86
const processed = {
79
87
code : compiled . css . toString ( ) ,
0 commit comments