Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Split a Gruntfile into multiple tasks/options files.
function loadConfig( path ) {
var glob = require( "glob" ),
object = {},
key;
glob.sync( "*", { cwd: path } ).forEach( function( option ) {
key = option.replace( /\.js$/, "" );
object[key] = require( path + option );
} );
return object;
}
module.exports = function( grunt ) {
var config = {
pkg: grunt.file.readJSON( "package.json" ),
env: process.env
};
/* Automatically load tasks. */
require( "load-grunt-tasks" )( grunt );
/* Load tasks options. */
grunt.util._.extend( config, loadConfig( "./tasks/options/" ) );
/* Load task definitions. */
grunt.loadTasks( "tasks" );
/* Initialize Grunt configuration. */
grunt.initConfig( config );
}
module.exports = function( grunt ) {
grunt.registerTask( "test", [
"uglify"
] );
};
module.exports = {
options: {
},
dist: {
src: ['js/*.js'],
dest: 'dist/<%= pkg.name %>.js'
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment