Gulp giving error for symbolic links in gulp.src ()

I have a symbolic link in the folder with images that points to another folder containing external images provided by a third-party library (managed by bower - gotta love javascript). As part of my build process, I compress all the images as follows:

gulp.task('images', function() { return gulp.src('static/img/**/*') .pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true })) .pipe(gulp.dest('dist/img')) }); 

When gulp gets into the symlink folder in the img folder, it returns

 events.js:72 throw er; // Unhandled 'error' event ^ Error: EISDIR, read 

Using gulp -debug shows that it binds to the symlink folder. I am on Mac OSX and a symlink was created using ln -s. Any ideas?

+5
source share
3 answers

gulp.src() uses node-glob , which does not scan symbolic links:

** If "globstar" is one in a part of the path, then it matches zero or more directories and subdirectories, looking for matches. It does not scan symbolic directories.

Please note that symbolic directories are not scanned as part of ** , although their contents may coincide with subsequent parts of the template. This prevents endless loops and duplicates, etc.

I don't know if this is supposedly a mistake or just skip them.

+5
source

I had the same problem pointing to a symlink folder. The solution was simple; vinyl-fs was just used.

 var vfs = require('vinyl-fs'); gulp.task('myTask', [], function() { vfs.src('static/img/**/*') .pipe(vfs.dest('dist/img')) )}; 
+3
source

You can use the "follow: true" option to make Gulp follow symbolic links. For instance:

 gulp.src('static/img/**/*', { follow: true }) 
+2
source

Source: https://habr.com/ru/post/1211673/


All Articles