null null - 1 year ago 119
Node.js Question

Gulp copying empty directories

In my gulp build I've made a task that runs after all compiling, uglifying and minification has occurred. This task simply copies everything from the src into the dest directory that hasn't been touched/processed by earlier tasks. The little issue I'm having is that this results in empty directories in the dest directory.

Is there a way to tell the

glob to only include files in the pattern matching (like providing the


Answer Source

Fixed it by adding a filter to the pipeline:

var es = require('event-stream');

var onlyDirs = function(es) {
  return, cb) {
      if (file.stat.isFile()) {
        return cb(null, file);
      } else {
        return cb();
// ...

var s = gulp.src(globs)
        .pipe(gulp.dest(folders.dest + '/' + module.folder));

// ...