Josee9988 / MinifyAll

A 𝗩𝗦𝗖𝗼𝗱𝗲 𝗺𝗢𝗻𝗢𝗳𝗢𝗲𝗿 for JS, JSON/C, CSS, and HTML, you will love its simplicity! 🌟 π˜Ύπ™€π™’π™₯π™§π™šπ™¨π™¨ and π™œπ™―π™žπ™₯ files and folders πŸ“¦ Reduce your bundle and file sizes with lightning speed ⚑
https://minifyall.jgracia.es/
GNU General Public License v3.0
71 stars 13 forks source link

Hex minimization brokes the minifier #92

Closed digiage closed 3 years ago

digiage commented 3 years ago

🐞 Bug Report

Describe the bug

seems like the minify CSS now stripping out the '%'. I found out it strips % for those in my css: width: 100%; ( -> width: 100; ... etc) height: 100%; -webkit-text-size-adjust: 100%; -ms-flex: 0 0 100%; flex: 0 0 100%; max-width: 100%; -ms-flex: 0 0 50%; flex: 0 0 50%; max-width: 50%; border-color: hsl(188deg 54% 70%); ( -> border-color: hsl(188deg 54% 70);) -webkit-transform: translateX(110%); transform: translateX(110%); -webkit-transform: translateX(0%); transform: translateX(0%); top: 40%; max-width: 80%; top: -50%; bottom: -50%;

It also seems it keeps % for the float numbers like 16.6666%.


Is this a regression?

I believe so. I have made minifying before and it never broke the design.


To Reproduce

  1. Right click in document and select "Minify this document and preserver the original"

Expected behaviour

It will keep the percentage.


Media prove


Your environment


Additional context

*

Josee9988 commented 3 years ago

I uploaded a new version with this but apparently fixed. What MinifyAll version are you using?

digiage commented 3 years ago

Thanks for fast reply. It was v2.5.11, but there was a message like "refresh needed...". So I clicked that and now no minified file is exported. I get this message: Command 'Minify this document and preserve the original ⛏' resulted in an error (command 'extension.MinifyAll2OtherDoc' not found)

Josee9988 commented 3 years ago

@digiage I have checked your code with the version I just published this morning and it doesn't remove the "%" characters. Please check your MinifyAll version is 2.5.11

Try it and if the issue still persists comment again. Thanks and sorry for the inconvenience!

Josee9988 commented 3 years ago

Thanks for fast reply. It was v2.5.11, but there was a message like "refresh needed...". So I clicked that and now no minified file is exported. I get this message: Command 'Minify this document and preserve the original ⛏' resulted in an error (command 'extension.MinifyAll2OtherDoc' not found)

Please restart VSCode and this should go away

digiage commented 3 years ago

Thank you, but I have restarted VSC, uninstall and reinstal MinifyAll and restarted Windows. Nothing happens when I use the 'Minify this document and preserve the original' or other two commands. Error message is not there, but also no files are exported now. If I run the command from the Ctrl + Shift + P, then I get this message again (Command 'Minify this document and preserve the original ⛏' resulted in an error...)

Josee9988 commented 3 years ago

Can you run the command Minify the selected text or Minify this document? Because I know there is an issue with the right click minify this document and preserve the original in Windows.

digiage commented 3 years ago

This does not work too. I have tried other projects and also independent files with no luck. The right click on 'Minify this document and preserve the original' worked well before even on Win.

digiage commented 3 years ago

The issue still throws thiss error: Command 'Minify the selected document and preserve the original πŸ’Ž' resulted in an error (command 'extension.MinifyAll2OtherDocSelected' not found)

Josee9988 commented 3 years ago

I only added 2 regex expressions in today's update. There should not be anything related to the "command not found" error.

Josee9988 commented 3 years ago

I've researching and as I expected this seems like a VSCode/Windows bug. Most of the people fix this by reinstalling the extension. But I would recommend removing it and looking for the VSCode extension file path and manually removing the extension folder if it is not removed. Anyways I'll try to look for more information

Josee9988 commented 3 years ago

Seems like the out/ folder hasn't been uploaded to the vscode marketplace so any command will be found. I will fix it ASAP

Josee9988 commented 3 years ago

Please update to the newest version and this should be fixed!

digiage commented 3 years ago

perfect. works well now. thanks

digiage commented 3 years ago

hi, sorry to bother you again, but it again stopped working. again exactly the same issue.

Josee9988 commented 3 years ago

Like, suddenly? Did it work for you before right?

digiage commented 3 years ago

exactly, I am not sure how that is possible. It worked after your changes. still version v2.5.12. No method works. I also reinstaled plugin again and still the same. The only setting I changed was -min to .min and then to -min again. When ctrl + shift + p used, then again this message. image

Josee9988 commented 3 years ago

Well that's weird. Could you go to the VSCode extensions folder, and see inside the extension if there is an out/ folder? Or if the node_modules folder is there?

digiage commented 3 years ago

yes, they are image

Josee9988 commented 3 years ago

Are they empty?

digiage commented 3 years ago

no. if you need any other folder content, just let me know. image

Josee9988 commented 3 years ago

Ok thanks! I'll try to think for something

digiage commented 3 years ago

thank you. I investigate furthermore and found out that JS seems to be minified and some of css too. there is issue just with those marked css (in this particular project). Now I have the ending set to '-min'. image

Josee9988 commented 3 years ago

Do the other commands work? Or only the one you click in the explorer the file and minifies without opening the file?

digiage commented 3 years ago

yes. all the commands the same, except portions like "Minify selected text". That one I used to find the issue by minifiing parts of the file. The issue seems like a combination of comas and rgb, but when there are comas and spaces it works (rgb(226,226,226) vs rgb(226, 226, 226)). rgba works with comas, spaces works too. if I play around with the notation in files which did not work before, then it starts to work even with commands with ⛏ and πŸ’Ž.

Here are some examples which might help to spot it:

doesn't work:

background-color: rgb(48,75,138,.96); background-color: rgb(48,75,138); background: radial-gradient(rgba(156, 215, 232, .92), rgb(80,186,214)); background: linear-gradient(69deg,rgb(206, 66, 108, .91) 0,rgb(80, 186, 214, .94) 100%); background-color: rgb(226,226,226);

works:

background-color:rgb(48 75 138); background: radial-gradient(hsl(342deg 59% 62%), #ce426c); background: radial-gradient(hsl(215.8, 63.9%, 69.6%), #4d7bbe); border: 1px solid rgb(226, 226, 226); background: linear-gradient(69deg,rgb(206 66 108 .91) 0,rgb(80 186 214 .94) 100%); background: linear-gradient(69deg,rgba(206, 66, 108, .91) 0,rgba(80, 186, 214, .94) 100%);

Josee9988 commented 3 years ago

I'll take a deeper look at it

Josee9988 commented 3 years ago

Could you try it again with the newest version (2.5.18) I've been really checking the deployment and what the causes might be, and I think I've fixed it, but I would like an extra confirmation of yours :)

digiage commented 3 years ago

Sorry to say, but at least some still persist. I upgraded and also later deleted (folders of extension) and reinstalled. I have made the css for testing if you want. Attaching test.css.txt

Josee9988 commented 3 years ago

@digiage , I attach a video minifying the file you sent me (I only added a class to not make the vscode shout for incorrect code πŸ˜†)

So, all the minimization that i'm performing in the video doesn't work in your machine, right?

Video prove

digiage commented 3 years ago

It looks different, then in mine. Isn't there anything in your VSCode which changes the syntax for colors? As of what I see, the issue is with rgb and comas (without spaces). I hope I got it correctly that the rgb() and rgba() should be equivalents so they both should take alpha parameter (https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). In your video for linear-gradient there is rgb() with space and rgba() with comas. Both works for me too. for radial-gradient you have hsl, I have one parameter rgb(80,186,214).

Attaching animated gif of how it looks at mine. Hope that helps minifyAll

digiage commented 3 years ago

@digiage , I attach a video minifying the file you sent me (I only added a class to not make the vscode shout for incorrect code πŸ˜†)

So, all the minimization that i'm performing in the video doesn't work in your machine, right?

Video prove

oh, I see, in your video example you have the part mentioned under "works". Which is the code that I found working well :-)

Josee9988 commented 3 years ago

@digiage , I attach a video minifying the file you sent me (I only added a class to not make the vscode shout for incorrect code laughing) So, all the minimization that i'm performing in the video doesn't work in your machine, right? Video prove

oh, I see, in your video example you have the part mentioned under "works". Which is the code that I found working well :-)

Video with the part under "doesn't work"

Josee9988 commented 3 years ago

I also send you a video with all the extensions disabled but MinifyAll, so we can surely say that no other extension is interfering. Also I'm using all the default minifyall settings. the vid

Josee9988 commented 3 years ago

So exactly what the problem is with these two codes? Is the issue from the 'command not found' fixed?

Thanks for all your patiente ❀️ :octocat:

digiage commented 3 years ago

you nailed it. I disabled all the extensions with --disable-extensions, then enabled one by one and guess what... it works now with all extensions enabled. so, I am really not sure where the issue could have been.

Thank you for your time and quick replies and sorry to got you stucked for a bit.

Josee9988 commented 3 years ago

Wow, so the issue will probably be caused by other extensions! You might try to disable one by one to try to see which one might be causing the problem.

We might consider this issue as solved, right? πŸ˜„

digiage commented 3 years ago

Yes, probably, but they are all enabled and it works now :-D So i guess I will not find out by disabling.

Yes, please consider the issue resolved. Gracias y saludos

Josee9988 commented 3 years ago

This is a complete headache πŸ˜†, we will probably never know!! Remember to star the project to see the upcoming bug-free features 🀣

If anything else happens feel free to post another issue and I'll be happy to help if I can.

Thanks for all.

digiage commented 3 years ago

Sorry to reopen. The issue appeared again. In settings I switched off hexa shortener, restarted VSC and minifiing stopped to work. So, I probably found the issue. It works well, if Disable Hexadecimal Shortener is checked. If unchecked, then it won't work for my code (some types of color notations). I apparently also have to close VSC and reopen it for settings changes (hexa shortener) to apply.

Josee9988 commented 3 years ago

Give some code samples and what the expected values are if anything is wrong.

digiage commented 3 years ago

Steps to reproduce:

  1. uncheck the Disable Hexadecimal Shortener in plugin settings.
  2. restart the VSC
  3. use this CSS in a file: .test{ background-color: rgb(48,75,138,.96); background-color: rgb(48,75,138); background: radial-gradient(rgba(156, 215, 232, .92), rgb(80,186,214)); background: linear-gradient(69deg,rgb(206, 66, 108, .91) 0,rgb(80, 186, 214, .94) 100%); background-color: rgb(226,226,226); }
  4. try to minify whole or parts of the file -> this does not work
Josee9988 commented 3 years ago

Ok, it doesn't work for me either. I'll take a look at it

Josee9988 commented 3 years ago

Please check v2.5.21 as this might at least make the minifier to work

digiage commented 3 years ago

thank you! I have tested a few cases and files and it seems to work well. Not sure if the settings option "hexa shortener" has any impact if selected or not, but this does is not crucial ;-)

Josee9988 commented 3 years ago

Hi again @digiage I've fixed the MinifyAllCore colour minifier, it seems that for hsl values or rgba, it throws an error, so I only added a couple of try-catch clauses to check if the minimization could be done or it failed.

And the setting hexa shortener was indeed crucial.

So... everything works back again right? Should we close this issue or is anything else to be reviewed.

Thanks for your patient ❀️

digiage commented 3 years ago

Perfect. thanks. I think you can close this one. If you want, check if the minify shortener has now any effect (if it shortens colors) when unchecked, but that does not belong to this thread. Have a good one.

Josee9988 commented 3 years ago

It doesn't minify colours if unchecked. But for now, it will not minify colours if the minifier doesn't understand the colour format. So it will not minify the colours even if set to it, but just in some scenarios where you are using 'hsl' or other functions. Maybe rgba might also not be minified.

Sorry for the inconvenience! I'll try to fix it when I buy some free time