Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
79
rated 0 times [  86] [ 7]  / answers: 1 / hits: 28170  / 9 Years ago, sun, january 17, 2016, 12:00:00

I have an app. My app source code is structured like this:



./
gulpfile.js
src
img
bg.png
logo.png
data
list.json
favicon.ico
web.config
index.html
deploy


I am trying to use Gulp to copy two files: ./img/bg.png and ./data/list.json. I want to copy these two files to the root of the deploy directory. In other words, the result of the task should have:



./
deploy
imgs
bg.png
data
list.json


How do I write a Gulp task to do this type of copying? The thing that is confusing me is the fact that I want my task to copy two seperate files instead of files that fit a pattern. I know if I had a pattern, I could do this:



var copy = require('gulp-copy');
gulp.task('copy-resources', function() {
return gulp.src('./src/img/*.png')
.pipe(gulp.dest('./deploy'))
;
});


Yet, I'm still not sure how to do this with two seperate files.



Thanks


More From » gulp

 Answers
-4

You can create separate tasks for each target directory, and then combine them using a general copy-resources task.



gulp.task('copy-img', function() {
return gulp.src('./src/img/*.png')
.pipe(gulp.dest('./deploy/imgs'));
});

gulp.task('copy-data', function() {
return gulp.src('./src/data/*.json')
.pipe(gulp.dest('./deploy/data'));
});

gulp.task('copy-resources', ['copy-img', 'copy-data']);

[#63681] Friday, January 15, 2016, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jeanettee

Total Points: 209
Total Questions: 97
Total Answers: 98

Location: Papua New Guinea
Member since Thu, Jul 9, 2020
4 Years ago
;