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

391
Visualizações
minify also html with vite.js: how to make vite bundle on npm run build delete comments or tabs in html?

I have a javascript project that uses the vite bundle. https://vitejs.dev/

CSS, and JS get minified successfully on https://vercel.com production site

but HTML have still the comments <!-- comments -->

(I am using javascript vanilla, no react)

I've seen the GitHub issue tab, but do not understand anything (and the thing they technically solve aren't listed on the DOCS webpage)

  • here: https://github.com/vitejs/vite/pull/793 (i've saw something like apply config, but docs don't show how to use it, or flush)

basically, I want that dev environment have comments that show the details of something,
but on production, the comments don't get pushed.


here I tried to do a simplified example (not a real example) to show the problem:

enter image description here

why production have the <!-- <button> --> while js with all comments get deleted. (and also how to delete spaces, and tabs in HTML for smaller gzip files index.html


I want to be like this:

enter image description here

(here a tool that minify https://www.willpeavy.com/tools/minifier/)


if you tried with vite and don't work,
I will tell you a hint:

from what I know vite use rollup under the hood, so maybe there is a config in rollup that can work well for vite, do you find some docs about it?

I use vite to not care about config or have less config possible, but maybe is this the case to use configs.

about 4 years ago · Juan Pablo Isaza
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