在CI/CD或批量处理中使用这些命令。
Node.jshtml-minifier-terser(通配符)
npx html-minifier-terser --collapse-whitespace --remove-comments --remove-optional-tags --minify-css true --minify-js true -o dist/index.min.html src/index.html流行的基于Node的HTML压缩工具,支持CSS/JS选项
Linux/macOSminify-html(Rust,极速)
minify-html --keep-whitespace=false --minify-css --minify-js src/index.html > dist/index.min.html通过cargo或包管理器安装;性能卓越
WindowsPowerShell + html-minifier-terser
npx html-minifier-terser --collapse-whitespace --remove-comments -o .\dist\index.min.html .\src\index.html适用于PowerShell或CMD