9uzttg
Last Updated: September 26, 2018
·
28.64K
· iondrimba

Simple Gulp Copy file task

This is just a handy way of copying a file from one folder to another.
There is no goal of replacing other tools out there.
No extra lib or package needed.

gulp.task('copy', function () {
    gulp.src('./src/templates/index.html')
        .pipe(gulp.dest('./public/'));
});

2 Responses
Add your response

30227

I use:

// copyTo.js v1
function copyTo(files, dest) {
if (typeof files == 'string') {
files = [files];
};
gulp.src(files).pipe(gulp.dest(dest));
console.log(cliDate() + ' copyTo success');
};

// cliDate.js v1
function cliDate() {
let date = new Date(),
hours = date.getHours(),
minutes = date.getMinutes(),
seconds = date.getSeconds();
hours < 10 ? hours = '0' + hours : hours;
minutes < 10 ? minutes = '0' + minutes : minutes;
seconds < 10 ? seconds = '0' + seconds : seconds;
return '[' + hours + ':' + minutes + ':' + seconds + ']';
};

3 months ago ·
30733

You can also use globs to match directories and files:


gulp.task('vendor', function () {
return gulp
.src([
'./nodemodules/bootstrap/dist/',
'./nodemodules/intl/dist/
'
], { base: 'nodemodules' })
.pipe(gulp.dest('./vendor/'));
});
29 days ago ·