terser / html-minifier-terser

actively maintained fork of html-minifier - minify HTML, CSS and JS code using terser - supports ES6 code
https://terser.org/html-minifier-terser
MIT License
385 stars 32 forks source link

[Bug]: `<!--#-->` comments are not removed #155

Open samualtnorman opened 1 year ago

samualtnorman commented 1 year ago

What happened?

removeComments: true removes all comments except those that start with #.

If this is intentional behaviour, it would be neat if we had a flag to override it.

Version

v7.2.0

What browsers are you seeing the problem on?

Firefox, Chrome, Safari

Link to reproduce

https://stackblitz.com/edit/stackblitz-starters-trumlr?file=index.js

Relevant log output

No response

Willing to submit a PR?

No

DanielRuf commented 3 weeks ago

If this is intentional behaviour, it would be neat if we had a flag to override it.

Yes, see the ignoreCustomComments setting, that you can change.

https://github.com/terser/html-minifier-terser?tab=readme-ov-file#options-quick-reference

ignoreCustomComments Array of regex'es that allow to ignore certain comments, when matched [ /^!/, /^\s*#/ ]

So in your case removing , /^\s*#/ should work.