E
E
Evgeny Demin2019-12-17 22:46:46
gulp.js
Evgeny Demin, 2019-12-17 22:46:46

How to exclude all contents of a directory in gulp.src but leave .htaccess in it?

It is necessary to exclude the contents of the cache folder in the build task, leaving only the .htaccess file in it.
Task content:

gulp.task('build', gulp.series('clean', function () {
    return gulp.src([
        "app/**/*",
        "!app/cache/**/*",
        "app/cache/.htaccess",
    ], {allowEmpty: true, dot: true})   
        .pipe(gulp.dest('dist'));
}));

It turns out to either save all the content, including the unnecessary cache, or only an empty folder remains without the .htaccess file.
Tried many options, nothing works. Please tell me how to exclude this file.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question