Jonathan Van Winkle
Tasks that I do regularly that grunt do for me:
Currently there are 2,215 plugins available.
Note: "Official" plugins begin with grunt-contrib-
$ sudo apt-get install g++ curl libssl-dev apache2-utils
$ sudo apt-get install git-core
Go to the node.js website and click the install button: nodejs.org
OR...
$ curl https://raw.github.com/creationix/nvm/master/install.sh | sh
$ source ~/.nvm/nvm.sh
$ nvm install 0.10
##################################################### 100.0%
Now using node v0.10.24
$ node -v
v0.10.24
$ npm install -g grunt-cli
{
"name": "my-project-name",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-jshint": "~0.6.3",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-watch": "~0.5.3"
}
}
Contains the following:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
build: {
src: 'src/<%= pkg.name %>.js',
dest: 'build/<%= pkg.name %>.min.js'
}
}
});
// Load the plugins
grunt.loadNpmTasks('grunt-contrib-uglify');
// Default task(s).
grunt.registerTask('default', ['uglify']);
};
npm install grunt-imagine --save-dev
This will install the imagine plugin. Adding "--save-dev" will add the plugin to the package.json file.
grunt.loadNpmTasks('grunt-imagemine');
Add this to gruntfile.js to enable the plugin
The actual configuration within gruntfile.js for imagine
pngmin: {
src: [
'components/img/*.png',
],
dest: 'temp/'
},
gifmin: {
src: ['components/img/*.gif'],
dest: 'temp/'
},
jpgmin: {
src: ['components/img/*.jpg'],
dest: 'temp/',
quality: 72
},
I packaged these tasks into one master imgmin task and entered "grunt imgmin"
Running "grunt imgmin" task
>> Compressed 33 files
>> Uncompressed size: 19039.49kb, Compressed size: 18433.62kb, Savings: 3.18%
Running "jpgmin" task
>> Compressed 1 files
>> Uncompressed size: 754.99kb, Compressed size: 130.3kb, Savings: 82.74%
Running "gifmin" task
>> Compressed 1 files
>> Uncompressed size: 58.66kb, Compressed size: 58.66kb, Savings: 0%
Running "copy:main" (copy) task
Copied 34 files
Grunt saves you time so you can spend it on other higher level pursuits like slot machines or bitcoin mining