marksmccann / node-sass-extra

A drop-in replacement for node-sass' Node API that adds support for globs, promises and more.
MIT License
2 stars 1 forks source link

Handling partials and excluding files in the Node API #39

Closed marksmccann closed 5 years ago

marksmccann commented 5 years ago

We need to consider how to handle partials, and how we intend to enable the user to exclude them. The node-sass node API doesn't do anything to exclude them. The CLI, when importing from a directory uses the follow configuration:

// globPath === '**/*.{sass,scss}' or '*.{sass,scss}'
glob(globPath, { ignore: '**/_*', follow: options.follow }, ...);

If desired how should a user exclude partials, or any pattern they desire, in our Node API?

First, we could do nothing and they could simply do this —

sass.render('**/!(_)*.scss');

However, what happens when they have more complex patterns, or multiple patterns? Should they be able to do something like this —

sass.render('**/*.scss', {
    exclude: [
        '**/_*',
        'some-other-file.scss'
    ]
})

Also, what happens if they want to take advantage of additional glob options, like 'follow'? While, less elegant, the following would maximize capability/versatility and would be very handy when mapping the CLI to the node API —

sass.render('**/*.scss', {
    globOptions: {
        ignore: '**/_*',
        follow: true
    }
})