Roman Makarov2016-01-26 14:15:15
Roman Makarov, 2016-01-26 14:15:15

Another problem with gulp async. How to decide?

You can see the problem in the screenshot
. run-sequence works, but since there is more than 1 file in the minification task, then the concatenation occurs before all files are minified.

var gulp = require('gulp'),
    autoprefixer = require('gulp-autoprefixer'),
    cssnano = require('gulp-cssnano'),
    uglify = require('gulp-uglify'),
    rename = require('gulp-rename'),
    concat = require('gulp-concat'),
    notify = require('gulp-notify'),
    watch = require('gulp-watch'),
    seq = require('run-sequence');

Tasks themselves:
gulp.task('admin-css-min', function () {
    return gulp.src('assets/css/admin/*')
        .pipe(autoprefixer('last 2 version'))
        .pipe(notify('a-css-min : complete'));
gulp.task('admin-css', function () {
    return gulp.src('assets/dist/css/admin/*')
        .pipe(notify('admin-css : complete'));
gulp.task('build-a-css', function () {
    return seq(['admin-css-min', 'admin-css']);

There is also the issue of optimization. Those. either caching here, or with the help of gulp-watch, minify only those files that have changed. How is it implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Alexey Strukov, 2016-01-26

In the last task, leave only minification. In the minification task, make the concatenation task a dependency.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question