Skip to content

Instantly share code, notes, and snippets.

@Integralist
Last active October 20, 2017 07:39
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Integralist/7464000 to your computer and use it in GitHub Desktop.
Save Integralist/7464000 to your computer and use it in GitHub Desktop.
Example of how to structure your Grunt files
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
// Store your Package file so you can reference its specific data whenever necessary
pkg: grunt.file.readJSON('package.json')
// ...tasks...
});
// Default task
grunt.registerTask('default', ['...']);
// Load custom tasks...
require('./grunt-customtasks.js')(grunt);
};
module.exports = function (grunt) {
"use strict";
var tasks = require('./scripts/grunt')(grunt); // this points to a directory and not a file (there should be an index.js inside the directory for this to work)
grunt.registerTask('noop', 'A no-operation task -> useful in testing situations', tasks.noop.runTask);
};
"use strict";
module.exports = function (grunt) {
return {
noop: require('./noop.js')(grunt) // result of scripts/grunt/noop.js is stored on the 'noop' property
};
};
"use strict";
module.exports = function (grunt) {
return {
runTask: function runNoopTask () {
grunt.log.writeln("noop run");
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment