@@ -475,12 +475,12 @@ Minification reduces file size and is enabled by default.
475475
476476The minifiers used are:
477477
478- | File type | Minifier used |
479- | ------------------------ | -------------------------------------------------------------------------- |
480- | js module and js classic | [ terser] ( https://github.com/terser/terser ) <sup >↗</sup > |
481- | html and svg | [ html-minifier] ( https://github.com/kangax /html-minifier ) <sup >↗</sup > |
482- | css | [ lightningcss] ( https://github.com/parcel-bundler/lightningcss ) <sup >↗</sup > |
483- | json | White spaces are removed using JSON.stringify |
478+ | File type | Minifier used |
479+ | ------------------------ | ---------------------------------------------------------------------------------- |
480+ | js module and js classic | [ terser] ( https://github.com/terser/terser ) <sup >↗</sup > |
481+ | html and svg | [ html-minifier-terser ] ( https://github.com/terser /html-minifier-terser ) <sup >↗</sup > |
482+ | css | [ lightningcss] ( https://github.com/parcel-bundler/lightningcss ) <sup >↗</sup > |
483+ | json | White spaces are removed using JSON.stringify |
484484
485485You can configure which files to minify:
486486
@@ -507,6 +507,32 @@ await build({
507507
508508To disable minification, use ` minification: false ` .
509509
510+ ### HTML comments
511+
512+ HTML is minified with comments removed. Some comments are meaningful after the
513+ build though: a marker a server looks for to inject content, a server side
514+ include, a legal banner. These are preserved:
515+
516+ ``` html
517+ <!-- ! kept: starts with "!" -->
518+ <!-- # kept: server side include -->
519+ <!-- removed -->
520+ ```
521+
522+ Use ` keepComments ` to change which comments survive; the comment text, without
523+ ` <!-- ` and ` --> ` , is tested against each regexp:
524+
525+ ``` js
526+ minification: {
527+ html: {
528+ // keep "<!-- INJECT_HERE -->" on top of the default ones
529+ keepComments: [/ ^ !/ , / ^ \s * #/ , / INJECT/ ],
530+ },
531+ },
532+ ```
533+
534+ Use ` html: { removeComments: false } ` to keep every comment.
535+
510536## 2.5 Build urls
511537
512538By default, URLs in the build are absolute and versioned:
0 commit comments