There is a task with the help of gulp to run recursively inside which minify (for example) all css files

var gulp = require('gulp'), concatCSS = require('gulp-concat-css'), concat = require('gulp-concat'), notify = require('gulp-notify'), streamqueue = require('streamqueue'), jsmin = require('gulp-jsmin'), autoprefixer = require('gulp-autoprefixer'), csso = require('gulp-csso'), rename = require('gulp-rename'); gulp.task('css', function () { return streamqueue({objectMode: true}, gulp.src([ 'www/BEM/Block/Common/Page/Page.css' , "www/BEM/Block/**/*.css" , "!www/BEM/Block/**/*_print.css" ]) ) // минификация ( ΠΌΠΎΠΆΠ½ΠΎ ΠΎΡ‚ΠΊΠ»ΡŽΡ‡Π°Ρ‚ΡŒ Ссли захочСтся ) .pipe(concatCSS("style.css")) // автопрСфиксСр .pipe(autoprefixer({browsers: ['last 3 versions']})) .pipe(csso()) .pipe(gulp.dest('www/public_html/docs/css/')) .pipe(notify('Бобрался css !')); }); 

I tried different options with gulp.dist (...) including

 gulp.dist(function(file){ return file.base }) 

sometimes it was even collected but errors were falling in the console (various)

How will do the right thing?

  • there is no pipe (gulp.dest ('.')) put in the same directory in which gulpfile.js, and I need to either in www / BEM / Block / Common / Page / or in www / BEM / Block / ** Depending on which directory the file has changed - Vladimir Petrozavodsk

2 answers 2

So you tried?

 .pipe(gulp.dest('.')) 

    I cite the solution I found:

      var gulp = require('gulp'), concatCSS = require('gulp-concat-css'), concat = require('gulp-concat'), notify = require('gulp-notify'), streamqueue = require('streamqueue'), jsmin = require('gulp-jsmin'), autoprefixer = require('gulp-autoprefixer'), csso = require('gulp-csso'), rename = require('gulp-rename'); gulp.task('css', function () { return streamqueue({objectMode: true}, gulp.src([ 'www/BEM/Block/Common/Page/Page.css' , "www/BEM/Block/**/*.css" , "!www/BEM/Block/**/*_print.css" ]) ) // минификация ( ΠΌΠΎΠΆΠ½ΠΎ ΠΎΡ‚ΠΊΠ»ΡŽΡ‡Π°Ρ‚ΡŒ Ссли захочСтся ) .pipe(concatCSS("style.css")) // автопрСфиксСр .pipe(autoprefixer({browsers: ['last 3 versions']})) .pipe(csso()) .pipe(gulp.dest('www/public_html/docs/css/')) .pipe(gulp.dest(function(file){ return file.base; })); }); 

    As it turned out, it was not very difficult to do.