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 />

grunt.initConfig({<br />

clean: {<br />

dist: ["dist/"]<br />

},<br />

jshint: {<br />

dist: ['Gruntfile.js', 'js/**/*.js', 'test/**/*.js']<br />

},<br />

concat: {<br />

dist: {<br />

src: ["js/**/*.js"],<br />

dest: "dist/js/scripts.js"<br />

}<br />

},<br />

uglify: {<br />

dist: {<br />

src: ["dist/js/scripts.js"],<br />

dest: "dist/js/scripts.min.js"<br />

}<br />

}<br />

});<br />

grunt.loadNpmTasks("grunt-contrib-clean");<br />

grunt.loadNpmTasks("grunt-contrib-jshint");<br />

grunt.loadNpmTasks("grunt-contrib-concat");<br />

grunt.loadNpmTasks("grunt-contrib-uglify");<br />

grunt.registerTask("dist", ["clean", "jshint", "concat",<br />

"uglify"]);<br />

}<br />

5. Copying step: There are many files such as images, fonts, and others that just<br />

need to be copied to the distribution without any change. This can be done<br />

using the grunt-contrib-copy plugin, which is capable of copying files and<br />

folders. The installation process is done with the following command:<br />

npm install grunt-contrib-copy --save-dev<br />

The configuration involves the source and destination of each folder and file,<br />

as follows:<br />

Gruntfile.js<br />

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

grunt.initConfig({<br />

clean: {<br />

[ 150 ]<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!