Get all files except minified files in gulp.src

1.2k views Asked by At

I try to select all files EXCEPT minified files.

I have this file structure :

lib/
    angular/
        angular.js
        angular.min.js
    lodash/
        lodash.js
        lodash.min.js

I try this :

var pattern = ["./lib/**/*!(.min).*"];
gulp.src(pattern).pipe(using({}));

But this doesn't works : i get all files, even if they are minified.

(With gulp-using i get :

[gulp] Using file ./lib/angular/angular.js
[gulp] Using file ./lib/angular/angular.min.js
[gulp] Using file ./lib/lodash/lodash.js
[gulp] Using file ./lib/lodash/lodash.min.js

)

Any idea ?

Thanks you in advance for your help

2

There are 2 answers

0
Aya Salama On BEST ANSWER

I know this question has been asked 3 years ago, but I will post this answer, so it might help someone else.

var pattern = ["./lib/**/!(*.min)*.js"];

and if you need to add multiple excludes, so, for example, you want to exclude fileName.js, *.spec and also all *.min files you can use |

var pattern = ["./lib/**/!(fileName|*.spec|*.min)*.js"];
1
psalaets On

Change pattern to

var pattern = ["./lib/**/*", "!./lib/**/*.min.*"];

This reads as "get all files anywhere under lib, then exclude files under lib that have '.min.' in their name"