@@ -15,7 +15,7 @@ class Core {
1515 let parser = new Parser ( pathFetcher , trace ) ;
1616
1717 return postcss ( this . plugins . concat ( [ parser . plugin ( ) ] ) )
18- . process ( sourceString , { from : "/" + sourcePath } )
18+ . process ( sourceString , { from : sourcePath } )
1919 . then ( ( result ) => {
2020 return {
2121 injectableSource : result . css ,
@@ -44,6 +44,14 @@ const traceKeySorter = (a, b) => {
4444
4545export default class FileSystemLoader {
4646 constructor ( root , plugins ) {
47+ if ( root === '/' && process . platform === "win32" ) {
48+ const cwdDrive = process . cwd ( ) . slice ( 0 , 3 )
49+ if ( ! / ^ [ A - Z ] : \\ $ / . test ( cwdDrive ) ) {
50+ throw new Error ( `Failed to obtain root from "${ process . cwd ( ) } ".` )
51+ }
52+ root = cwdDrive
53+ }
54+
4755 this . root = root ;
4856 this . sources = { } ;
4957 this . traces = { } ;
@@ -59,12 +67,12 @@ export default class FileSystemLoader {
5967 let relativeDir = path . dirname ( relativeTo ) ,
6068 rootRelativePath = path . resolve ( relativeDir , newPath ) ,
6169 fileRelativePath = path . resolve (
62- path . join ( this . root , relativeDir ) ,
70+ path . resolve ( this . root , relativeDir ) ,
6371 newPath
6472 ) ;
6573
6674 // if the path is not relative or absolute, try to resolve it in node_modules
67- if ( newPath [ 0 ] !== "." && newPath [ 0 ] !== "/" ) {
75+ if ( newPath [ 0 ] !== "." && ! path . isAbsolute ( newPath ) ) {
6876 try {
6977 fileRelativePath = require . resolve ( newPath ) ;
7078 } catch ( e ) {
0 commit comments