Sass Imports with Sass Globbing

29 / Jul / 2016 by Priyanka Agarwal 0 comments

If we are using Sass to preprocess stylesheets, we must have knowledge about partials. A partial is a sub-stylesheet, intended to be included as part of a main stylesheet. So as to avoid adding “partials” every time, we can use the sass-globbing gem to remove the extra overhead.

Sass Globbing to rescue

Sass-globbing is a Ruby gem for Sass. It lets us import directories or whole directory trees with a single @import statement:
Instead of including absolute paths for eg:

// Modules and Variables
@import "partials/base";
// Partials
@import "partials/reset";
@import "partials/typography";
@import "partials/buttons";

We can do something like this:

@import "partials/*";
@import "partials/**/*"

The first one includes all the files in the partials folder.
The second one includes all the files in the partials folder recursively.

To start using the gem, we’ll install it from the command line:

$ gem install sass-globbing

after this installation we can easily import the partials folder.

Usage of Sass command line

When we are using scss global plugin then we convert scss to css using below command:

$ sass -r sass-globbing --watch sass_dir:css_dir
FOUND THIS USEFUL? SHARE IT

Leave a comment -