D
D
Dmitry Sergeevich2015-11-15 15:31:09
JavaScript
Dmitry Sergeevich, 2015-11-15 15:31:09

How to split a stream into multiple files in Gulp.js?

Hello everyone, I have one task in gulpfile.js:

var global_css = [
        './source/sass/global/*.scss',
        './source/sass/features/*.scss',
        './source/sass/pages/*.scss',
        './source/sass/layout/*.scss'
    ];

gulp.task('sass-global', function () {

            return gulp.src(global_css)
                .pipe(plugins.plumber({errorHandler: plugins.notify.onError("<%= error.message %>")}))
                .pipe(plugins.sourcemaps.init())
                .pipe(plugins.sass())
                .pipe(plugins.autoprefixer({
                    browsers: prefix_list,
                    cascade: false
                }))
                .pipe(plugins.csscomb('./dev/libs/comb/research.json'))
                .pipe(plugins.sourcemaps.write('./'))
                .pipe(gulp.dest('./public/css'));
        });

Is it possible to make it so that in one such task, each specified folder in global_css is concatenated into a separate file and then CSScomb Prehifire and SursMap are passed through this file?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Yarosh, 2015-11-15
@CheckOneTwo

var merge = require('merge-stream');
gulp.task('sass-global', function () {
  var merged = merge();
  global_css.forEach((entry) => {
    merged.add(gulp.src(entry)
      .pipe(plugins.plumber({errorHandler: plugins.notify.onError("<%= error.message %>")}))
      .pipe(plugins.sourcemaps.init())
      .pipe(plugins.sass())
      .pipe(plugins.autoprefixer({
        browsers: prefix_list,
        cascade: false
      }))
      .pipe(plugins.csscomb('./dev/libs/comb/research.json'))
      .pipe(plugins.sourcemaps.write('./'))
      .pipe(gulp.dest('./public/css')));
  });

  return merged;
});

Like so

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question