Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
gulp apis
Lets start using Gulp 3.8
https://github.com/johnpapa/pluralsight-gulp
why use a task runner -> oe more tool to add to your toolbox, solves repetition, consistently
preparing javascript/html/css for production - minify and concatenate, 1 file instead of 10 or thousands
less to css compilation
inhecting files into html
cache busting
angular template cache
testing
code analysis
Whats in it for you - improve quality, deliver faster, repeatable and consistent.
work smarter, not harder
gulp apis
1 - gulp.task (name[,dep] ,fn)
gulp.task('js', function() {
return gulp
.src('./src/**/*.js')
.pipe(concat('all.js')
.pipe(uglify())
.pipe(gulp.dest('./build/'));
});
gulp.task('js', ['jscs', 'jshint'], function() {
return gulp
.src('./src/**/*.js')
.pipe(concat('all.js')
.pipe(uglify())
.pipe(gulp.dest('./build/'));
});
2 - gulp.src (gob, [,options])
gulp.task('min1', function() {
return gulp
.src('./src/**/*.js', {base: './src/'})
.pipe(uglify())
.pipe(gulp.dest('./build/'));
});
The above Writes ./src/app/admi,/admin.js to
./build/app/admin/admin.js
gulp.task('min1', function() {
return gulp
.src('./src/**/*.js')
.pipe(uglify())
.pipe(gulp.dest('./build/'));
});
3 - gulp.dest (folder [,options])
4 - gulp.watch (glob [, options], tasks)
gulp.task('lint-watcher', function() {
(gulp.watch('./src/**/*.js', [
'jshint',
'jscs'
]);
});
gulp.task('lint-watcher', function() {
(gulp.watch('./src/**/*.less', function(event){
console.log('watched event ' + event.type + ' for ' + event.path);
});
});
use gulp.watch when tests run, code lints, or compile to css
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.