Created
August 7, 2015 19:14
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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