I am running grunt on my app to jshinting and minification, In which jshint is working but the minification command not working at all. getting error like this:
D:\grunt>grunt min
Warning: Task "min" not found. Use --force to continue.
Aborted due to warnings.
here is my config file:
module.exports = function(grunt){
// Project configuration.
grunt.initConfig({
jshint: {
options: {
curly: true,
eqeqeq: true,
eqnull: true,
browser: true,
globals: {
jQuery: true
}
},
myFiles: ['js/**/*.js']
},
min:{
dest : {
src:'js/app.js',
dest:'js/app.min.js'
}
},
});
// Each plugin must be loaded following this pattern
grunt.loadNpmTasks('grunt-contrib-jshint');
}
In this project I have the modules installed is :
grunt, grunt-contrib-jshint, jshint - I don't know the wrong what i do..
Any one help me to figure-out the issue please.
thanks in advance!
To minify files you need, for example, uglify.
Install it with this command:
npm install grunt-contrib-uglify --save-dev
Then, add it in your Gruntfile
grunt.loadNpmTasks('grunt-contrib-uglify');
Finally, you have to change the code of your Gruntfile:
grunt.initConfig({
jshint: {
options: {
curly: true,
eqeqeq: true,
eqnull: true,
browser: true,
globals: {
jQuery: true
}
},
myFiles: ['js/**/*.js']
},
uglify:{
dest : {
files: {
'js/app.min.js': ['js/app.js']
}
}
},
});
Regards.
You need to install a minify task like
grunt-contrib-uglify
in order to minify the files.
More on Grunt-contrib-uglify