Skip to content

Instantly share code, notes, and snippets.

@leopic
Created August 7, 2015 19:14
Show Gist options
  • Save leopic/96cce83e477374cf627d to your computer and use it in GitHub Desktop.
Save leopic/96cce83e477374cf627d to your computer and use it in GitHub Desktop.
make a list of all the stylesheets that need to be processed, then start cranking away
/**
* Generates our CSS files using libsass.
* Wrapper for the `sass` task, make sure you have installed all the dependencies of the repo.
*
* Example: $: grunt libsass
* $: grunt libsass:dev
*
* @param env
*/
grunt.registerTask('libsass', 'Builds our CSS', function(env) {
var done = this.async(),
dir = require('node-dir'),
list = {},
pkg = grunt.file.readJSON('package.json');
// Override config options for dev.
if (env && env == 'dev') {
grunt.config.set('sass.options.sourceMap', true);
grunt.config.set('sass.options.sourceComments', true);
grunt.config.set('sass.options.outputStyle', 'expanded');
}
dir.readFiles(pkg.paths.styles, {
match: /.scss$/,
exclude: /^_/
}, function(err, content, next) {
if (err) throw err;
next();
},
function(err, files) {
if (err) throw err;
files.forEach(function(val) {
list[val.replace('styles', 'css').replace('scss', 'css')] = val;
});
grunt.config.set('sass.dist.files', list);
grunt.task.run(['clean:css', 'mkdir:css', 'sass']);
done();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment