-
-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
minimize=true is stripping invalid css #213
Comments
Please open issue in |
I'm not sure it's exactly a bug in html-minifier. There is an option |
Workaround - set |
Solution There is a way to prevent that: This is already supported through
|
So actually not a bug ;-) |
@DanielRuf Unfortunately this is not the best behavior, in theory in future developers can use new CSS syntax and due clean-css do not support that it is break code, so it is bug, will be great to keep |
I don't agree with this. Not possible without breaking the current implementation. Also wrapping everything in a style attribute into these comments prevents minifying css at all in the style attributes which makes not much sense. This should be controllable and it is controllable with these comments. It is just not documented. |
Really? Would you expect from a babel or typescript empty string on invalid syntax or you wait an exception and keep a code in files as is? Or maybe prettier should write an empty string too when you have invalid syntax 😄 As i written in the original issue, we should got an exception when a syntax is broken, so when we got an exception we return original string instead return empty string. |
Afaik html-minifier and clean-css accept and generate only valid code. |
See my reply in the linked issue. It should normally. This is an upstream issue in clean-css as far as I can see. |
The problem is that clean-css does not recognize the new syntax what support new browsers and return broken code, so it is bug. |
The issue was about something else:
|
I understand that the minimizer is trying to optimise for size, but in the process it strips invalid css from a style tag. I believe that this is undesirable behaviour.
In a normal case that might actually be the right thing to do, but some libraries/frameworks/loaders might depend on a not-valid-css string to be there to perform custom transformations or custom behaviour.
Expected Output for
{attrs: false, minimize: true}
<div style="invalid css here">
Actual Output for
{attrs: false, minimize: true}
<div style="">
.Expected Output for
{attrs: false, minimize: false}
<div style="invalid css here">
Actual Output for
{attrs: false, minimize: false}
<div style="invalid css here">
Code
The text was updated successfully, but these errors were encountered: