GruntJs
GruntJs Task Builder Api
4 flashcards · Programming Languages · by lakesare
What does grunt.registerTask() do? module.exports = function(grunt) { grunt.registerTask('hello', ['sass', 'browserify:dist', 'emailBuilder']); };
This method supports the following two signatures: ALIAS TASK: grunt.registerTask('hello', ['sass', 'browserify:dist', 'emailBuilder']); Now if we run grunt hello these tasks will run in order. FUNCTION TASK: grunt.task.registerTask('foo', 'A sample task that logs stuff.', function(arg1, arg2) { grunt.log.writeln(this.name + ", " + arg1 + " " + arg2); }); (In both cases we can pass description as a second argument) This example alias task defines a "default" task whereby the "jshint", "qunit",…
What does grunt.loadNpmTasks() do? module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-watch'); };
Load tasks from the specified Grunt plugin. This plugin must be installed locally via npm. For most projects, tasks will be defined in the Gruntfile. For larger projects, tasks can be loaded from one or more external directories or Npm-installed Grunt plugins.
What does grunt.loadTasks() do? module.exports = function(grunt) { grunt.loadTasks('hello'); };
grunt.loadTask('hello') will load every JS file in the 'hello' directory: project root |- hello |--- file.js |- Gruntfile.js // hello/file.js module.exports = function(grunt) { grunt.registerTask('build', function(which) { /* Contents of the task... */ }); };
What does load-grunt-tasks module do? module.exports = function(grunt) { require('load-grunt-tasks')(grunt); }
Automatically runs loadNpmTasks for all grunt npm modules installed. Before grunt.loadNpmTasks('grunt-shell'); grunt.loadNpmTasks('grunt-sass'); grunt.loadNpmTasks('grunt-recess'); grunt.loadNpmTasks('grunt-sizediff'); grunt.loadNpmTasks('grunt-svgmin'); grunt.loadNpmTasks('grunt-styl'); grunt.loadNpmTasks('grunt-php'); grunt.loadNpmTasks('grunt-eslint'); grunt.loadNpmTasks('grunt-concurrent'); grunt.loadNpmTasks('grunt-bower-requirejs'); After require('load-grunt-tasks')(grunt);