nicoespeon / sass-graph-viz

Draw a visual graph of Sass dependencies
https://medium.com/@nicoespeon/i-built-a-tool-to-work-with-complicated-sass-codebases-b5c909e269fb
MIT License
25 stars 2 forks source link

Support "loadPaths"? #26

Closed kerryj89 closed 3 years ago

kerryj89 commented 3 years ago

Previously I would hardlink to each partial directly (ie @import "../../../some-package/scss/header") which worked great. However I have refactored to @import "some-package/scss/header so that other projects can use my SCSS and let the consumers define where this package is located (gulp, webpack, etc, through SCSS loadPaths option) instead of assuming the same directory structure. I see sass-graph has this option - is there a way to pass this option to sass-graph through your sassgraphviz command?

nicoespeon commented 3 years ago

@kerryj89 excellent suggestion!

I implemented the support, it is available with v2.4.0.

You should be able to provide the extra load path to locate the SASS files with -l, --load-paths in the CLI, or loadPaths: string[] if you're using the library programmatically.

Here's an example: https://github.com/nicoespeon/sass-graph-viz/tree/master/examples/load-paths fixtures/packages was added to the load paths, so importing some-package/header from fixtures/application (our target) will resolve the file located at fixtures/packages/some-package/_header.scss 👍

kerryj89 commented 3 years ago

Can confirm it works - thanks so much!