How to make the galp add files to the same directories

gulp.task('templates', function() { 'use strict'; var includeDirs = ['app/pages/', 'app/blocks/**']; return gulp.src(['app/pages/*.njk','app/blocks/**/*.njk']) .pipe(rename({extname: ".html"})) // допустим мы поменяли формат .pipe(gulp.dest() // теперь надо вставить файлы в те же директории ... ... }); 

    1 answer 1

    If you really have the way you wrote, first, you forgot to close the bracket after gulp.dest() . Secondly, to get the path, use the function with getting .base to return the path value of the file location.

    It should look like this:

      gulp.task('templates', function() { 'use strict'; var includeDirs = ['app/pages/', 'app/blocks/**']; return gulp.src(['app/pages/*.njk','app/blocks/**/*.njk']) .pipe(rename({extname: ".html"})) .pipe(gulp.dest(function(file){ return file.base; }) ) ... ... });