Created by Øyvind Marthinsen / @oyvinmar
Why?
Many frontend task not adequately solved by these tools
Repeat when a src file changes
gulp.task('somename', function() {
// Do stuff
});
gulp.task('build', ['somename', 'test'];
> gulp build
gulp.src('client/templates/*.jade')
.pipe(jade())
gulp.src(['src/**/*.js', 'test/spec/**/*.js'])
.pipe(jshint())
gulp.src('./client/templates/*.jade')
.pipe(jade())
.pipe(gulp.dest('./build/templates'))
.pipe(minify())
.pipe(gulp.dest('./build/minified_templates'));
gulp.watch('app/**/*.js', ['test','reload']);
gulp.task('scripts', function () {
return gulp.src('src/app/**/*.js') // <-- read from filesystem
// In memory transform
.pipe(jshint('.jshintrc')) // <-- lint the code
.pipe(concat('app.min.js')) // <-- concatenate to one file
.pipe(uglify()) // <-- minify the file
.pipe(rev()) // <-- add revision to filename
.pipe(gulp.dest('dist/app')); // <-- write to filesystem
});
But we already use a build system!
Run Gulp.js from your build system
gulp.task('serve', function () {
connect.server({
port: 3000,
middleware: function () {
return [ (function () {
var url = require('url');
var proxy = require('proxy-middleware');
var options = url.parse('http://localhost:7000/api/');
options.route = '/api';
return proxy(options);
})() ];
}
});
});