Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

385
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!