gulpglobminimatch

Get all files except minified files in gulp.src


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


Solution

  • 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"];