Shiva
Shiva

Reputation: 56

Using Gulp Concat along with Gulp Changed

I currently use gulp for most of my automation tasks. To keep the process optimised I check for file changes before processing the file. The problem is that when I rebuild my files and only a single file in the set has changed, the concat file only includes the changed file. Is there a way to pickup all the files in case of concat

gulp.task('myScripts', function() {
    return gulp.src(['public/js/one.js','public/js/two.js'], {base: 'public/js'})
    .pipe(changed('public/dist/original/js'))
    .pipe(gulp.dest('public/dist/original/js'))
    .pipe(uglify())
    .pipe(concat('all.min.js'))
    .pipe(gulp.dest('public/dist/js'));
});

I am using gulp-changed to check for file changes, Here are the scenarios:

  1. When running it for the first time, it takes both the miles and minifies them.
  2. When only one file is changed after that, the concatenated file 'all.min.js' only contains the minified version of the changed file.

Can anyone please help me with how I can concat all the files even if only one file changes?

Upvotes: 1

Views: 983

Answers (1)

Ghidello
Ghidello

Reputation: 1863

You should require gulp-remember and call it before concat. Gulp-remember works with gulp-changed and restores the previous changed files into the stream.

Have a look to this official recipe: Incremental rebuilding, including operating on full file sets

Upvotes: 2

Related Questions