Parses scss string and returns an array of filenames that the
@import directives resolve.
Install with npm
npm install sass-import-resolve
Say you have a file
/test/scss/screen.scss with content...
to find out what file paths match to the patterns above, you do...
var resolve = ;var fs = ;var sassStr = fs;console;//=> [ '/test/scss/a.sass',//=> '/test/scss/_a.sass',//=> '/test/scss/a.scss',//=> '/test/scss/_a.scss',//=> '/test/b/a.sass',//=> '/test/b/_a.sass',//=> '/test/b/a.scss',//=> '/test/b/_a.scss',//=> '/test/scss/c.scss',//=> '/test/scss/_d.sass',//=> '/test/scss/_d.scss' ]
Please Note: This module does not know and care about your files. The file and it's content does not have to exist. It also doesn't care if the resolved paths exist. It's job is only to resolve sass
The module should be compatible with all the rules described in the sass docmentation for
A regular name for a partial to import does resolve to 4 filenames.
a.scss a.sass _a.scss _a.sass
If the name is prefixed with underscore it only resolves to 2 filenames.
If the name has a Sass or SCSS extension then it resolves only to 1 filename. It doesn't matter if the name is prefixed with underscore or not.
"a.css", "url('a')", "http://"
As per sass documentation, there are a few circumstances when
@import directive will not resolve at all:
- If the file’s extension is .css.
- If the filename begins with http://.
- If the filename is a url().
- If the @import has any media queries. (this one is not implemented yet)
resolve(filename, sassStr [, options])
Array of filenames that all
@import directives in
sassStr do resolve.
The filenames resolve relative to the
There are few options that affects the result of the resolve method.
Weather you want the Sass files to be resolved.
Weather you want the SCSS files to be resolved.
Weather you want to resolve files that are prefixed with underscore.
Note: If your import path is already prefixed. E.g.
@import "_a", this option is ignored, and only prefixed paths will resolve.
Weather you want to resolve files that are not prefixed with underscore.
npm install npm test