E
E
enchikiben2018-02-05 16:04:23
gulp.js
enchikiben, 2018-02-05 16:04:23

How to limit file selection in gulp?

Good evening!
There is a directory with N directories in one of the directories (folder_js, for example) there are files file1.js, file2.js..., file1.min.js, file2.min.js...
I need to copy the contents of the entire directory to another except , not minified folder_js directory files,
I do like this :

gulp.src([
   "/**/*",
   "!/**/folder_js/*.js",
   "/**/folder_js/*.min.js"
])

but something is not working, tell me how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolai Shabalin, 2018-02-05
@EnChikiben

The problem with the array is srcthat gulp iterates over each key in sequence.
I could filtern't do it without

const gulp = require('gulp');
const filter = require('gulp-filter');

return gulp.src('src/**/*')
    .pipe(filter(
        ['**/*', '!src/folder_js/*.js', 'src/folder_js/*.min.js']
    ))
    .pipe(gulp.dest('www'));

I think this can be improved.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question