dlmanning / gulp-sass

SASS plugin for gulp
MIT License
1.57k stars 381 forks source link

Passing includePath as an array #868

Open StfBauer opened 1 year ago

StfBauer commented 1 year ago

In my gulp task, I'd liked to do something like this.

        .pipe(
            $.if(!isProd, sass.sync({
                outputStyle: 'expanded',
                precision: 6,
                includePaths: module.paths,
                disableDeprecationWarnings: true
            }))
            .on('error', sass.logError))

module.paths is a predefined variable containing all the node_modules search paths to find installed packages. It returns already an array in the current form:

[
  '/Volumes/Code/customer/project/styleguide/node_modules',
  '/Volumes/Code/customer/project/node_modules',
  '/Volumes/Code/customer/node_modules',
  '/Volumes/Code/node_modules',
  '/Volumes/node_modules',
  '/node_modules'
]

This hasn't worked as expected, so I had to convert it to a string instead.

let incPath = module.paths.join(',');

Then I passed that into my sass compile task.

        .pipe(
            $.if(!isProd, sass.sync({
                outputStyle: 'expanded',
                precision: 6,
                includePaths: incPath,
                disableDeprecationWarnings: true
            }))
            .on('error', sass.logError))

I guess I found the issue here:

https://github.com/dlmanning/gulp-sass/blob/c04bb67043fdbcb930152232ee9ba4caff0b2599/index.js#L122-L134

It only checks for strings rather than for a path array. Is it safe to submit a PR for this change, or is there any reason more technical reason behind the check for the string story?

Happy to contribute this small adjustment.