Load external grunt tasks with a single function

This commit is contained in:
Stephen Bégay
2015-04-03 15:26:13 -04:00
parent 44356da29a
commit 47cf83f00f
2 changed files with 19 additions and 32 deletions

View File

@@ -1,39 +1,25 @@
module.exports = function(grunt) {
grunt.initConfig({
function loadConfig(path) {
var glob = require('glob');
var object = {};
var key;
pkg: grunt.file.readJSON('package.json'),
glob.sync('*', {cwd: path}).forEach(function(option) {
key = option.replace(/\.js$/,'');
object[key] = require(path + option);
});
// watch: Run tasks whenever watched files change.
watch : require('./grunt_tasks/watch'),
return object;
}
// sass: Compile Sass to CSS
sass: require('./grunt_tasks/sass'),
// autoprefixer: Parse CSS and add vendor prefixes to CSS rules using values from the Can I Use website
autoprefixer : require('./grunt_tasks/autoprefixer'),
// csscomb: Sort CSS properties in specific order.
csscomb : require('./grunt_tasks/csscomb'),
// cssmin: Compress CSS files
cssmin : require('./grunt_tasks/cssmin'),
// svgstore: Merge svgs from a folder
svgstore: require('./grunt_tasks/svgstore'),
// svgmin: Minify SVG
svgmin : require('./grunt_tasks/cssmin'),
// concat: Concatenate files.
concat: require('./grunt_tasks/concat'),
// uglify: Minify (javascript)files with UglifyJS
uglify : require('./grunt_tasks/uglify'),
// notify: Automatic Notifications when Grunt tasks fail (or succeed)
notify : require('./grunt_tasks/notify')
});
var config = {
pkg: grunt.file.readJSON('package.json')
}
grunt.loadTasks('grunt_tasks');
grunt.util._.extend(config, loadConfig('./grunt_tasks/'));
grunt.initConfig(config);
// Load tasks
require('load-grunt-tasks')(grunt);

View File

@@ -18,6 +18,7 @@
"grunt-sass": "0.0.0",
"grunt-svgmin": "0.0.0",
"grunt-svgstore": "0.0.0",
"load-grunt-tasks" : "0.0.0"
"load-grunt-tasks" : "0.0.0",
"glob": "0.0.0"
}
}