D
D
DenJel2015-07-31 16:34:57
gulp.js
DenJel, 2015-07-31 16:34:57

Gulp: what's wrong with script, synchronous call? URL change?

Please help me figure out what is wrong with the task? All tasks work separately, but I can't make a synchronous chain, first fontmin - a font converter, then fonts-concat - combine everything into 1 css and then clean - delete all css's, except for the one generated by the previous task.
That is, when calling gulp, fonts must first work out the previous 2 tasks. But it throws a Syntax Error. Unexpected token function, to a function that stands after the dependency.
Also, who knows how to implement changing the URLs in the final fonts.css. It lies in another folder with all the CSS's, but the URLs remain the same there, how to process them? I just need to add "../fonts/" to the beginning

gulp.task('fontmin', function() {
    return gulp.src('./fonts/ttf/*.ttf')
        .pipe(fontmin())
        .pipe(gulp.dest('./fonts/'));
});

gulp.task('fonts-concat', ['fontmin'] function() {
  return gulp.src('./fonts/*.css')
    .pipe(concat('fonts.css'))
    .pipe(gulp.dest('./css/'));
});

gulp.task('fonts', ['fonts-concat', 'fontmin'] function() {
    return gulp.src('./fonts/*.css', {read: false})
        .pipe(clean());
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Goryachkin, 2015-07-31
@DenJel

This is a feature of gulp, contrary to what you write in the last task:
Gulp will not execute them sequentially. But if you just write:

gulp.task('fonts', ['fonts-concat'] function() {
    return gulp.src('./fonts/*.css', {read: false})
        .pipe(clean());
});

Then fonts-concat will be launched before fonts , in turn, fontmin will be launched before fonts-concat and as a result you will get the desired chain. As for the address replacement, create another task using gulp-replace or its equivalent.
As an edge you can use gulp-run-sequence .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question