| 1. |
How To Run Multiple Tasks Together In Grunt? |
|
Answer» Every grunt module MAY have defined a task. But running them individually can make things difficult for developers. What is one wants to run grunt uglify and grunt jshint together Using grunt.registerTask(taskName, [description, ] taskList) we can group all the tasks under one roof. Task NAME can be anything of your choice, description is optional and task list is array of module tasks which you wish to execute. For example, grunt.registerTask('development', ['jshint:development', 'concat:development', 'uglify:development']); Above code creates a task named “development” and is asked to execute development target of “jshint”, “concat” and “uglify” packages. Similarly, you can register another task for PRODUCTION VERSION. grunt.registerTask('production', ['jshint:production', 'concat:production', 'uglify:production']); Remember, you always need to define a default task. grunt.registerTask('default', ['jshint', 'uglify', 'concat']); Now, when you enter grunt on command prompt, it will execute the default task. Every grunt module may have defined a task. But running them individually can make things difficult for developers. What is one wants to run grunt uglify and grunt jshint together Using grunt.registerTask(taskName, [description, ] taskList) we can group all the tasks under one roof. Task name can be anything of your choice, description is optional and task list is array of module tasks which you wish to execute. For example, grunt.registerTask('development', ['jshint:development', 'concat:development', 'uglify:development']); Above code creates a task named “development” and is asked to execute development target of “jshint”, “concat” and “uglify” packages. Similarly, you can register another task for production version. grunt.registerTask('production', ['jshint:production', 'concat:production', 'uglify:production']); Remember, you always need to define a default task. grunt.registerTask('default', ['jshint', 'uglify', 'concat']); Now, when you enter grunt on command prompt, it will execute the default task. |
|