how base option affects gulp.src & gulp.dest

(You’re not looking at the official gulp documentation. is just some guy’s fork of the gulpjs github repo. The official repo is where the base option is indeed documented.) To answer your question: If you don’t specify the base option yourself, then everything before the first glob in your gulp.src() paths is automatically … Read more

Using Gulp to Concatenate and Uglify files

It turns out that I needed to use gulp-rename and also output the concatenated file first before ‘uglification’. Here’s the code: var gulp = require(‘gulp’), gp_concat = require(‘gulp-concat’), gp_rename = require(‘gulp-rename’), gp_uglify = require(‘gulp-uglify’); gulp.task(‘js-fef’, function(){ return gulp.src([‘file1.js’, ‘file2.js’, ‘file3.js’]) .pipe(gp_concat(‘concat.js’)) .pipe(gulp.dest(‘dist’)) .pipe(gp_rename(‘uglify.js’)) .pipe(gp_uglify()) .pipe(gulp.dest(‘dist’)); }); gulp.task(‘default’, [‘js-fef’], function(){}); Coming from grunt it was a … Read more

Get the current file name in gulp.src()

I’m not sure how you want to use the file names, but one of these should help: If you just want to see the names, you can use something like gulp-debug, which lists the details of the vinyl file. Insert this anywhere you want a list, like so: var gulp = require(‘gulp’), debug = require(‘gulp-debug’); … Read more

What is the ** glob character?

It’s almost the same as the single asterisk but may consist of multiple directory levels. In other words, while /x/*/y will match entries like: /x/a/y /x/b/y and so on (with only one directory level in the wildcard section), the double asterisk /x/**/y will also match things like: /x/any/number/of/levels/y with the concept of “any number of … Read more

Pass Parameter to Gulp Task

It’s a feature programs cannot stay without. You can try yargs. npm install –save-dev yargs You can use it like this: gulp mytask –production –test 1234 In the code, for example: var argv = require(‘yargs’).argv; var isProduction = (argv.production === undefined) ? false : true; For your understanding: > gulp watch console.log(argv.production === undefined); <– … Read more