Как, как.. Джаваскриптом об косяк =)))
Нужно скопировать файлы? Не вопрос! Напишем задачу копирования.
global.ROOT = 'корень проекта';
let config = {
root: {
build: 'dist'
}
};
config.copy = [
{ src: 'source/assets/**', dest: '/'},
{ src: 'source/assets/.htaccess', dest: '/'},
{ src: 'node_modules/tiny-slider/dist/tiny-slider.js', dest: '/design/js' },
{ src: 'node_modules/tiny-slider/dist/tiny-slider.css', dest: '/design/css' },
{ src: 'node_modules/cool-menu/dist/cool-menu.js', dest: '/design/js' },
{ src: 'node_modules/svg4everybody/dist/svg4everybody.js', dest: '/design/js' },
{ src: 'node_modules/vanilla-text-mask/dist/vanillaTextMask.js', dest: '/design/js' },
{ src: 'node_modules/tippy.js/dist/tippy.all.min.js', dest: '/design/js' },
];
function copyFiles(conf, options) {
return new Promise((resolve, reject) => {
if (!('src' in conf)) reject('Invalid config for "copy" task: undefined "src" param');
if (!('dest' in conf)) conf.dest = '';
if ('extensions' in conf) { }
let source = path.join(global.ROOT, conf.src);
let dest = path.join(global.ROOT, options.root.build, conf.dest);
let pipeline = gulp.src(source).pipe(gulp.dest(dest));
pipeline.on('error', function (err) {
reject(err);
});
pipeline.on('end', function () {
resolve();
});
});
}
gulp.task('copy', function(done){
let copies = [];
options.copy.forEach(item => {
copies.push(copyFiles(item, options));
});
Promise.all(copies).then(value => done(), reason => done());
});