Created
September 13, 2015 19:21
-
-
Save gsuttie/004291c3496e665c839a to your computer and use it in GitHub Desktop.
gulp apis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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