How to copy multiple files and keep the folder structure with Gulp

后端 未结 3 1519
谎友^
谎友^ 2020-12-22 23:20

I am trying to copy files from one folder to another folder using Gulp:

gulp.task(\'move-css\',function(){
  return gulp.src([
    \'./source/css/one.css\',
         


        
3条回答
  •  星月不相逢
    2020-12-23 00:14

    To achieve this please specify base.

    ¶ base - Specify the folder relative to the cwd. Default is where the glob begins. This is used to determine the file names when saving in .dest()


    In your case it would be:

    gulp.task('move-css',function(){
      return gulp.src([
          './source/css/one.css',
          './source/other/css/two.css'
      ],  {base: './source/'}) 
      .pipe(gulp.dest('./public/assets/'));
    });
    

    Folder structure:

    .
    ├── gulpfile.js
    ├── source
    │   ├── css
    │   └── other
    │       └── css
    └── public
        └── assets
    

提交回复
热议问题