Search code examples
javascriptgulp

How to use gulp changed or newer with the same folder being src and dest?


But as it compares the files, being the same folder, it gets a bit obvious that if they compare the same files, always be the same but I need the source and output files to be in the same folder, if anyone knows a solution, I will stay thankful. Like this example:

function webpConvert() {
    return src(folder + "/**/*.{jpg,png}")
        .pipe(newer(folder))
        .pipe(
            parallelCore(
                webp({
                    quality: 100,
                    lossless: true
                })
            ),
            os.cpus().length
        )
        .pipe(dest(folder))
}

I'm using gulp4.


Solution

  • It's not possible use Gulp-newer or Changed in cases of the same folder for both src and dest. You can use gulp-cache-files or gulp-file-cache.