16.07.2017 Views

AngularJS Essentials

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Automating the Workflow<br />

Installation<br />

Just like Karma, Grunt requires NodeJS and the Node Package Manager to<br />

be installed. To proceed with the installation, we just need to type in the<br />

following command:<br />

npm install -g grunt-cli grunt<br />

After this, we are ready to configure it!<br />

Configuration<br />

The Gruntfile.js file is the JavaScript file that defines the configuration of each<br />

task, plugin, and workflow. Let's take a look at its basic structure:<br />

module.exports = function (grunt) {<br />

// 1 – Configuring each task<br />

grunt.initConfig({<br />

});<br />

// 2 - Loading the plug-ins<br />

grunt.loadNpmTasks('plugin name');<br />

// 3 - Creating a workflow by grouping tasks together<br />

grunt.registerTask('taskName', ['task1','task2','task3']);<br />

}<br />

Also, it's really recommended that you generate the package.jsonfile file. It is<br />

important to track each dependency, and this file can be generated with the<br />

following command:<br />

npm init<br />

After this, you are ready to create your distribution package!<br />

[ 146 ]<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!