How to use Grunt in existing project
I am very glad to explain about the Grunt, because i feel it makes my life easy.
Always keep in mind, use your valuable time in creative activities, not in repetitive and boring tasks in web development.
In this context, grunt is very helpful for everyone.
So, a basic question is “What is Grunt?”
It is a task runner. Through which you can automate your most repetitive tasks.
For using grunt, first of all you have to install grunt-cli ( It would be more helpful if you installed grunt-cli globally in your system ). npm install -g grunt-cli
Note: If you don’t want to install grunt globally remove -g from given command.
A basic example of Grunt:
Follow these steps to configure Grunt in existing project
1. Install grunt ( run following command from project root directory)
npm install -S grunt
2. create Gruntfile.js in root directory
3. Write following code inside the Gruntfile.js
module.exports = function (grunt){
grunt.registerTask(‘singing’, function () {
console.log(‘I am Singing’);
});
grunt.registerTask(‘dancing’,function(){
console.log(‘I am dancing’);
});
grunt.registerTask(‘default’,function(){
console.log(‘I am acting’);
});
grunt.registerTask(‘both’,[‘singing’,’dancing’]);
}
4. Run following command and examine the output
grunt singing
grunt dancing
grunt both
grunt
For Reference: https://github.com/SatyamChaudhary8891/grunttutorial-grunt-1