G
G
Georgy Bukharov2017-06-08 09:14:28
JavaScript
Georgy Bukharov, 2017-06-08 09:14:28

How to combine multiple gulp tasks into one?

Here are my tasks:

// TTF to EOT, OTF, WOFF, SVG + font-face.css
gulp.task('fontmin', function() {
    return gulp.src('app/fonts/*.ttf')
        .pipe(fontmin())
        .pipe(gulp.dest('app/fonts'))
});

// all font-face.css files to app/fonts.css
gulp.task('fface',['fontmin'], function(){
    return gulp.src('app/fonts/*.css')
        .pipe(concat('fonts.css'))
        .pipe(gulp.dest('app/css'))
});

// Removes font-face.css from app/fonts
gulp.task('fonts', ['fface'], function(){
    return del.sync('app/fonts/*.css')
});

I want to optimize gulpfile and combine these tasks into one. Tried using merge-stream , but only 'fontminify' was executed.
gulp.task('fonts', function() {

    var fontminify = gulp.src('app/fonts/*.ttf')
        .pipe(fontmin())
        .pipe(gulp.dest('app/fonts'));

    var fface = gulp.src('app/fonts/*.css')
        .pipe(concat('fonts.css'))
        .pipe(gulp.dest('app/css'));

    var remove = del.sync('app/fonts/*.css');

    return merge(fontminify, fface, remove);
});

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
TobiraSoe, 2017-06-08
@TobiraSoe

Here is a simple option -

gulp.task("название общего таска", ["тут", "твои", "таски"]);

S
SindWebDeveloper, 2020-08-13
@SindWebDeveloper

gulp.task( 'fontWork',  gulp.series('fonts', 'fface', 'fontmin') );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question