Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
70
rated 0 times [  75] [ 5]  / answers: 1 / hits: 41999  / 9 Years ago, wed, may 6, 2015, 12:00:00

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',
'./source/other/css/two.css'

]).pipe(gulp.dest('./public/assets/css/'));
});


The above code is copying one.css & two.css to the public/assets/css folder.



And if I use gulp.src('./source/css/*.css') it will copy all CSS files to the public/assets/css folder which is not what I want.



How do I select multiple files and keep the folder structure?


More From » css

 Answers
47

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

[#66724] Monday, May 4, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
micayla

Total Points: 148
Total Questions: 92
Total Answers: 109

Location: Aruba
Member since Sat, Oct 2, 2021
3 Years ago
micayla questions
Fri, Dec 24, 21, 00:00, 2 Years ago
Thu, Apr 16, 20, 00:00, 4 Years ago
Thu, Nov 14, 19, 00:00, 5 Years ago
;