Answer the question
In order to leave comments, you need to log in
How to completely copy a directory in Gulp?
How to copy a folder exactly in Gulp? That is, in addition to the contents, there are also its child folders, also with their contents, etc. In my case, this is img/
Structure:
/
|= node_modules/
|= src/
| |= html/
| | |= index.html
| |= img/ #=> отсюда
| | |= gallery/
| | |= cards/
| | |= favicon.ico
| | |= logo.png
| |= sass/
|= dist/
| |= img/ #<= сюда
| |= css/
| |= index.html
|= package.json
|= package-lock.json
|= gulpfile.js
Answer the question
In order to leave comments, you need to log in
Here is a working gulpfile.js for your project structure:
"use strict";
const {src, dest} = require("gulp");
const gulp = require("gulp");
const gulpCopy = require('gulp-copy');
const outputPath = "dist/";
var path = {
build: {
html: "dist/",
images: "dist/"
},
src: {
html: "src/*.html",
images: ['src/img/**/*.*']
}
}
function images() {
return src(path.src.images)
.pipe(gulpCopy(outputPath, {prefix: 1}))
.pipe(dest(path.build.images));
}
const build = gulp.series(images);
exports.images = images;
exports.default = build;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question