gulp
Installation
_$: mkdir -p $HOME/gulp && cd $HOME/gulp
_$: npm install gulp-cli --global
_$: npm install gulp --local --save-dev
_$: npm install gulp-uglify --local --save-dev
Create a task
_$: touch gulpfile.js
/home/<user>/gulp/gulpfile.js:
------------------------------
var gulp = require('gulp'),
uglify = require('gulp-uglify');
gulp.task('hello', function () {
console.log('Hello world!');
});
gulp.task('minify', function () {
gulp.src('test.js')
.pipe(uglify())
.pipe(gulp.dest('build'))
});
/home/<user>/gulp/test.js:
--------------------------
var x = 'This is a test';
var y = 'And so is this';
console.log(x);
_$: gulp hello
[10:42:41] Using gulpfile ~/gulp/gulpfile.js
[10:42:41] Starting 'hello'...
Hello world!
[10:42:41] Finished 'hello' after 77 μs
_$: gulp minify
_$: cat ./build/test.js
var x="This is a test",y="And so is this";console.log(x);