There are two tasks: build:scss and build:js :

 gulp.task('build:scss', function () { return gulp.src(paths.src.scss) .pipe(scss({ includePaths: includePaths.scss })) .pipe(rev()) .pipe(gulp.dest('public/build')) .pipe(rev.manifest({ path: 'public/build/rev-manifest.json', merge: true })) .pipe(gulp.dest('')); }); gulp.task('build:js', function () { return gulp.src(paths.src.js) .pipe(rigger()) .pipe(rename('app.min.js')) .pipe(rev()) .pipe(gulp.dest('public/build')) .pipe(rev.manifest({ path: 'public/build/rev-manifest.json', merge: true })) .pipe(gulp.dest('')) }); 

There is also a sketch:

 gulp.task('watch', function () { watch([paths.watch.scss], function () { gulp.start('build:scss'); }); watch([paths.watch.js], function () { gulp.start('build:js'); }); }); 

The task : creating revisions of css and js files and writing their names in rev-manifest.json (all this in the watch calls of the players)

Current result : everything works, but if you change scss and js and save, then one of them is not written in the rev-manifest (in my case, css)

As I understand it, the question here is to synchronize write access to the rev-manifest file. Tell me, please, which way to dig?

Also, in order not to create a new question, tell me what to do with the old revision files? Now its own function has been written, but ... Surely there is a correct approach - I would like to know.

PS added gulp-sync to build task - it works fine, but it does not solve problems with watchdogs. And to run the build and js and scss when you change one of the files - probably not a very good solution. PPS I also tried to play with gulp-queue , however, as I understood, this is not exactly that.

    1 answer 1

    So, after several days of suffering, a solution was found:

    1. The gulp-sync plugin allows you to run tasks synchronously.
    2. I rejected the gulp-rev plugin in favor of gulp-rev-all
    3. I compiled / compiled js / scss into a separate task (called js / scss )
    4. The rev-manifest generation was also delivered to a separate task (there is also a function that removes the build folder with old files - it is written with pens, not a plugin)
    5. Created two new tasks: build: scss and build: js . They use gulpSync to run scss / js sequentially and then manifest .

    Essence: previously I wanted to do without saving non-revision files (without a hash in the name). Now, after the build / compilation, the files are placed in a temporary folder - conditionally tmp - which is in the gigignore.

    For each change of scss / js, the task will manifest delete the old build folder and create everything anew (files with hash + entries in the rev-manifest ).

    If we change js and scss + we will still lose the full build: the task manager will do the same job twice: deleting and creating new files.

    However, the solution works. If you know a more correct approach - please, unsubscribe here. I would be very grateful.

    Some code (in general):

     gulp.task('scss', function () { return gulp.src(paths.src.scss) .pipe(scss({ includePaths: includePaths.scss })) .pipe(rename('app.min.css')) .pipe(gulp.dest(paths.tmpFront)); }); gulp.task('build:scss', gulpSync.sync(['scss', 'manifest'])); gulp.task('js', function () { return gulp.src(paths.src.js) .pipe(rigger()) .pipe(rename('app.min.js')) .pipe(gulp.dest(paths.tmpFront)); }); gulp.task('build:js', gulpSync.sync(['js', 'manifest'])); gulp.task('manifest', function () { deleteOldRevisions(); return gulp.src(paths.tmpFront + '**/*') .pipe(revAll.revision()) .pipe(gulp.dest(paths.build.dest)) .pipe(revAll.manifestFile()) .pipe(gulp.dest(paths.build.dest)); }); 

    PS A better solution would be to organize a queue of tasks, which I tried to do with gulp-queue , but, alas, either my curvature or plug-in developers prevented this: the manifest did not register one of the empty files (the one that worked ). Why so - I did not understand. Perhaps you will be able to implement the queue - again I would appreciate it :)

    UPD: you can not crutches your miracle removal functions: plug-in del