Multiple file extensions in one directory using Gulp

So, I have a gulpfile.js setting.

In the image folder, I have several images, some are png, some jpg and some gif.

I want to configure all png, jpg and gif in the image folder.

I could use ** / * for the purpose of everything in the folder, but I do not want, I want it to be specific to file types.

I could also do this and specify each file type individually:

return gulp.src('./images/*.jpg', './images/*.png', './images/*.gif') 

But it repeats itself a lot, and it seems that there should be an easier way.

I am looking for something like this:

 return gulp.src('./images/*.{png, gif, jpg}') 

But, alas, the above does not work (or at least it only works for the first type of file in the list)

Does anyone know how to do this?

thank

+50
javascript gulp
Mar 05 '15 at 11:10
source share
2 answers

Take the spaces

 return gulp.src('./images/*.{png,gif,jpg}') 
+89
Nov 04 '15 at 15:02
source share

This glob template worked for me:

 return gulp.src('./images/*.+(jpg|jpeg|gif|png)') 

Note. Pay attention to the + sign, it does not work without it.

Found on minimization documentation .

+28
Nov 30 '15 at 7:12
source share



All Articles