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

319
Visualizações
How to reduce HTML to a single line with no whitespace via Gulp

I'm trying to minify HTML with Gulp to remove all line breaks and white space so the entire code content resides on one line only and with no redundant whitespace like tabs and spaces, including in embedded JavaScript and CSS.

I've tried gulp-minify, but I do not see the output or compression options for that, which leaves me cross-eyed. I thought that was one of the common functions of minification. This beautifier/minifier does precisely what I need via its minify button, but I need that functionality via Gulp.

Ok I'm going insane. Thanks in advance.

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

0

const gulp = require("gulp");
const minHTML = require('gulp-htmlmin');

gulp.task("htmlMin", function () {
  return (
    gulp
      .src("./*.html")
      .pipe(minHTML({ collapseWhitespace: true }))
      .pipe(gulp.dest("dist"))
  );
});

exports.default = gulp.series("htmlMin");

And run it with just gulp at the command line.

Using gulp-htmlmin as suggested by @Cully in the comments, and I already had.

  ~/replace ==>  gulp
[01:23:36] Using gulpfile ~\OneDrive\Test Bed\replace\gulpfile.js
[01:23:36] Starting 'default'...
[01:23:36] Starting 'htmlMin'...
[01:23:36] Finished 'htmlMin' after 127 ms
[01:23:36] Finished 'default' after 132 ms
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