AngularJS and Grunt

2016-06-08 23:05:34

AngularJS and minification

If you decided to minify your web application that you used AngularJS, you may need some steps to do it.

Check that your controller(s) defined below:

app.controller('HomeCtrl',function($scope,WebService){

......

});

 

Note: There is no need to define dependencies in brackets like:

app.controller('HomeCtrl', ['$scope',function($scope,

 

So lets do it!

 

1-make sure that grunt command installed on your system

2-create Gruntfile.js and paste below block.

module.exports = function(grunt) {

grunt.initConfig({
uglify: {
js: {
src:['/path/to/src/init.js','/path/to/src/**/*.js'], dest:'/path/to/src/minify.js' },
options: {
mangle: false
}
}

});

grunt.loadNpmTasks('grunt-contrib-uglify');

}; 

  3-

npm install grunt-contrib-uglify --save-dev

  4-run

grunt uglify

That's it! Good Luck.

Tags Cloud

AngularJS

Grunt

AngularJS minification

grunt-contrib-uglify

grunt uglify