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
376 stars 30 forks source link

Text between "<%" and "%>" not minified in script tag #120

Closed huahuahu closed 2 years ago

huahuahu commented 2 years ago

Bug report or Feature request? Bug Report

Version

npx html-minifier-terser -V
7.0.0-alpha.2

Complete CLI command or minify() options used

{
  removeAttributeQuotes: true,
  minifyJS: {
    format: {
        ascii_only: true,
    },
  },
}

input

'<script>consolg.log("<%你好%> 你好")</script><p title="blah" id="moo">foo</p>'

output or error

<script>consolg.log("<%你好%> \u4f60\u597d")</script><p title=blah id=moo>foo</p>

Expected result

<script>consolg.log("<%\u4f60\u597d%> \u4f60\u597d")</script><p title=blah id=moo>foo</p>
huahuahu commented 2 years ago

I think the reason is that the "<%你好%>" is treated as customFragment here

image
DanielRuf commented 2 years ago

Hi @huahuahu,

correct. There is a setting for this: ignoreCustomFragments

Not a bug but a feature since this was set by default for several and good reasons.

DanielRuf commented 2 years ago

Closing as this is not a bug but a feature. Please test with different settings for ignoreCustomFragments.