Search code examples
gulpglob

Get only the content of folder with glob


I'm currently trying to copy some files using gulp. To do this, I need to use a glob pattern to explain which files to copy.

I have a distfolder containing what i need, but every time I copy it, I get the dist folder copied as well.

It looks something like this.

gulp.src('./dist/**')

can someone help me here?


Solution

  • If you'd also set your destination, it will work as expected:

    gulp.task('distcopy', function() {
      return gulp.src('dist/**')
        .pipe(gulp.dest('foo'));
    });
    

    Now, index.html in dist/ will be copied to foo/index.html.