xzyfer / sass-graph

Parses import dependencies from a directory of sass files
MIT License
76 stars 59 forks source link

Imports aren't properly resolved #90

Closed Hoffs closed 6 years ago

Hoffs commented 6 years ago

Not sure if it's intended but if I specify loadsPaths: ['./src', './node_modules'] and parse directory src I dont get any imports/importedBy paths. If I specify paths as ['./'] it resolves them fine. My folder structure would be:

node_modules/.....
src/.....

so in reality I include both paths that are included by './' either way, but the result is different.

Hoffs commented 6 years ago

Well so I did some digging and I see whats happening. Its probably how its supposed to be, but basically if you have @import 'src/a.scss' and load path './src' in the end it will be looking at ./src/src/a.scss because of:

scssPath = path.normalize(loadPaths[i] + '/' + sassPathName + '.' + extensions[j]);

so it seems it wants root path based on your imports. This could be changed to check for files and load paths that share same folder (like ./src matches import src/a.scss) but that might have side effects.

xzyfer commented 6 years ago

You're correcy about the behvaiour. This emulates the import algorithm in Sass, which what this library is all about.

On 25 Feb. 2018 5:28 am, "Ignas Maslinskas" notifications@github.com wrote:

Well so I did some digging and I see whats happening. Its probably how its supposed to be, but basically if you have @import 'src/a.scss' and load path './src' in the end it will be looking at ./src/src/a.scss because of:

scssPath = path.normalize(loadPaths[i] + '/' + sassPathName + '.' + extensions[j]);

so it seems it wants root path based on your imports. This could be changed to check for files and load paths that share same folder (like ./src matches import src/a.scss) but that might have side effects.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/xzyfer/sass-graph/issues/90#issuecomment-368248912, or mute the thread https://github.com/notifications/unsubscribe-auth/AAjZWAnobB2rgigLsxeC-NxFFBFv3SE3ks5tYFTNgaJpZM4SR-xZ .