K
K
Kolya2016-12-19 10:37:25
Web development
Kolya, 2016-12-19 10:37:25

How to copy an array with directories from src to dest, gulp?

There are directories that I just need to copy from the src folder to build. But gulp takes only files from them and throws it in the root, if you specify 'base' it copies the entire structure including the src folder.
It should be like this:

из src/
         fonts/
         video/
в build/
         fonts/
         video/

and copy it like this:
из src/
         fonts/
         video/
в build/
         src/
              fonts/
              video/

Task:
var path = {
  build: {
    root: 'build/',
                ...
  },
  src: {
    root: 'src/',
                ...
    files: ['src/fonts/**/*', 'src/video/**/*']
  }
};

gulp.copy = function(src,dest) {
  return gulp.src(src, {base: '.'})
    .pipe(gulp.dest(dest));
};
gulp.task('files:prod', function() {
  return gulp.copy(path.src.files, path.build.root);
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question