Gulp Copying Files from one Directory to another

2019-04-03 10:37发布

问题:

I want to Gulp Copy Multiple Files

gulp.task('copy', function(){

     gulp.src(
        'bower_components/bootstrap/dist/js/bootstrap.js', 
        'bower_components/jquery/dist/jquery.min.js', 
        'bower_components/jquery.stellar/src/jquery.stellar.js',
        'bower_components/jquery-waypoints/waypoints.js',
        'bower_components/jquery-easing-original/jquery.easing.1.3.js')
    .pipe(gulp.dest('public/assets/js'));
});

To copy my files from my bower_components directory to my assets directory, but it is only working with the first line (bootstrap.js), all others are ignored.

I wouldn't like to pipe every single file to the destination directory.

How would I go about to do this?

regards,

George

P.S. I am using it just for devel. In production I would concatenate and minify them before I deploy them. Nonetheless I believe that the task is clear, I want the bower_components to show up my public folder. I think that it is a little bit tedious to have all the files on the bower_components folder, only to copy them into your public directory. Is there any other best practice to use the bower component files?

回答1:

Try to add [], like this:

gulp.src([
    'file1',
    'file2',
    'file3'
])
.pipe(gulp.dest('public/assets/js'));


标签: gulp bower