Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

299
Visualizações
How can I create a subfolder in each folder through Gulp?

Good day!

I want to automate the conversion of images to webp format. To avoid doing it manually or via online converters, I decided to use gulp 4 and gulp-webp.

This is the structure of nesting folders in my project:

enter image description here

I want Gulp, when it finds a picture, so that it creates a folder called "webp" at the same nesting level and places the converted picture in this folder.

I want the following result:

enter image description here

My Gulpfile.js:

let gulp = require('gulp'),
    webp = require('gulp-webp');

gulp.task('webp', () => {
    // './dev/img/**/*.{png,gif,jpg}' - all files in img and all files in subfolders in img


    return gulp.src('./dev/img/**/*.{png,gif,jpg}')
        .pipe(webp())
        .pipe(gulp.dest(gulp.src)) //something like this, but it doesn't work

    }
);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This can be done with the help of gulp-rename.

To install gulp-rename run:

npm i -D gulp-rename

Then in your gulpfile.js add the import:

const rename = require('gulp-rename');

Then change your stream like this:

return gulp.src('./dev/img/**/*.{png,gif,jpg}')
    .pipe(webp())
    .pipe(rename({ prefix: 'webp/' }))
    .pipe(gulp.dest('./dev/img'));

The prefix option inserts "webp/" before the bare filename after the dest target "./dev/img".

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda