Created by Zach Schneider / @zkm
Gulp is an automated task runner — or build process.
Speedtesting between gulp.js and Grunt
Sass compilation
Javascript minification and concatination using Uglify.js
Here is an example of a gruntfile.js
grunt.initConfig({
sass: {
dist: {
files: [{
cwd: 'app/styles',
src: '**/*.scss',
dest: '../.tmp/styles',
expand: true,
ext: '.css'
}]
}
},
autoprefixer: {
options: ['last 1 version'],
dist: {
files: [{
expand: true,
cwd: '.tmp/styles',
src: '{,*/}*.css',
dest: 'dist/styles'
}]
}
},
watch: {
styles: {
files: ['app/styles/{,*/}*.scss'],
tasks: ['sass:dist', 'autoprefixer:dist']
}
}
});
grunt.registerTask('default', ['styles', 'watch']);
Now here is an example of a gulpfile.js doing the same thing.
gulp.task('sass', function () {
gulp.src('app/styles/**/*.scss')
.pipe(sass())
.pipe(autoprefixer('last 1 version'))
.pipe(gulp.dest('dist/styles'));
});
gulp.task('default', function() {
gulp.run('sass');
gulp.watch('app/styles/**/*.scss', function() {
gulp.run('sass');
});
});
Leonardo da Vinci once said
“Simplicity is the ultimate sophistication.”
npm install -g gulp
npm install gulp gulp-util --save-dev
var gulp = require('gulp');
var gutil = require('gulp-util');
gulp.task('default', function(){
// Default task code
});
If you are looking for a simple and fast task runner solution, I would recommend using Gulp.