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

[BUG] minifyCSS parsing error if css class contains double dash (--) #125

Closed mikethm closed 2 years ago

mikethm commented 2 years ago

Minifying the following gives a blank style. It appears that if a comment is the first line, the next line is missed if the name has a double dash (e.g. in BEM naming convention)

<style>

.double--dash {
    /* the line after this is ignored */
    content: "hi";   
}

</style>
mikethm commented 2 years ago

can confirm by trying it on https://terser.org/html-minifier-terser/

DanielRuf commented 2 years ago

Hi @mikethm,

thanks for reporting this.

html-minifier uses a thirdparty dependency for CSS minifying. So if there is a bug please check this with clean-css: https://github.com/terser/html-minifier-terser/blob/v7.0.0-alpha.2/package.json#L78

https://github.com/clean-css/clean-css

Closing as I can reproduce this at https://clean-css.github.io/

grafik

grafik

Please report your finding at https://github.com/clean-css/clean-css/issues.

DanielRuf commented 2 years ago

Dug a bit deeper and found this: https://github.com/clean-css/clean-css/issues/1218#issuecomment-1086788075

sibiraj-s commented 2 years ago

The fix is merged but not yet released https://github.com/clean-css/clean-css/commits/master

DanielRuf commented 2 years ago

Not sure if this also covers the normal rules without @...: https://github.com/clean-css/clean-css/commit/40ca65807639e0470dab22585847a7582687167f#diff-8293806213899c77041113555d21f05f403e84479eb1b480180e2c486cf9b2bdL361