How to set gulp.dest() in same directory as pipe inputs?

Here are two answers. First: It is longer, less flexible and needs additional modules, but it works 20% faster and gives you logs for every folder. var merge = require(‘merge-stream’); var folders = [ “./pictures/news/”, “./pictures/product/original/”, “./pictures/product/big/”, “./pictures/product/middle/”, “./pictures/product/xsmall/”, … ]; gulp.task(‘optimizeImgs’, function () { var tasks = folders.map(function (element) { return gulp.src(element + ‘*’) … Read more

How can I use the path from gulp.src() in gulp.dest()?

in your src set the base option and it will maintain the original path of your less file. gulp.task(‘compileLess’, function () { gulp.src(‘./*/less/*.less’, {base: ‘./’}) .pipe(less()) .pipe(gulp.dest( ‘./dist’ )); }); The ./dist destination can be anything. Wherever you want your file structure to be placed. Additional info here: https://github.com/wearefractal/glob-stream#options

Gulpjs combine two tasks into a single task

I think the proper way of doing this is using task dependency. In gulp you can define tasks that needs to be run before a given task. For instance: gulp.task(‘scripts’, [‘clean’], function () { // gulp.src( … }); When doing gulp scripts in the Terminal, clean is run before the scripts task. In your example … Read more

How to run a gulp task from another task?

I did it using gulp.start(); like this: gulp.task(‘test1’, function(){ gulp.start(‘test2’); }) gulp.task(‘test2′, function(){ // do something }) I was using gulp 3.9.1 if it matters. Looks like gulp.start() may be removed or deprecated; but it hasn’t happened yet. Update If I were to break things out into separate functions, as Novellizator suggested, it would be … Read more

Gulp uglify output min.js

You can use the suffix or extname parameters of gulp-rename like: gulp.task(‘compressjs’, function () { gulp.src(‘app/**/*.js’) .pipe(uglify()) .pipe(rename({ suffix: ‘.min’ })) .pipe(gulp.dest(‘dist’)) })

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

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)