coderaiser / minify

Minifier of js, css, html and img
https://coderaiser.github.io/minify
MIT License
225 stars 29 forks source link

All background:url(...) encoded as base64 #40

Closed rynomster closed 7 years ago

rynomster commented 7 years ago

Hi Guys

I've been using this package for a few months now in a build script. I'm currently travelling so I had to install it on my crackbook pro. I'm not sure what version I was running at home, as I don't have my pc with me, but it seems everything is importing as base64 encoded uris instead of the relative uri's.

Looking at changes in the past few versions, I would think this is related to clean-css, but I can't seem to see any changes there either.

Is there an option to not encode the images as base64 and just leave them as relatively pathed uri's in my css?

Thanks in advance :)

kewde commented 7 years ago

@rynomster https://github.com/coderaiser/minify/commit/2e4dbb0b0aab9d49e8aba695c42fc9f063cd9ad9

Maybe that relates?

coderaiser commented 7 years ago

@rynomster There is no such way. minify not customizable: it is it's pros and cons.

@kewde There was a bug related to absence of encoding images to base64, this commit is the fix of a bug.

Images encoded with base64 could be much bigger (then not encoded), but there is a limit to not encode big enough images.

Why do you need it?

rynomster commented 7 years ago

Thanks for replying. We compile our images into our executable, as it's c++, previously it never used to encode the images, so the css files were much smaller. Ill have a look at clean-css and how it deals with images.

On Oct 31, 2016 16:36, "coderaiser" notifications@github.com wrote:

@rynomster https://github.com/rynomster There is no such way. minify not customizable: it is it's pros and cons.

@kewde https://github.com/kewde There was a bug related to absence of encoding images to base64, this commit is the fix of a bug.

Images encoded with base64 could be much bigger (then not encoded), but there is a limit https://github.com/coderaiser/minify/blob/master/lib/img.js#L10 to not encode big enough images.

Why do you need it?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/coderaiser/minify/issues/40#issuecomment-257310309, or mute the thread https://github.com/notifications/unsubscribe-auth/AGl7FbVa_ai_6AujdFu9POduSwqQq9pgks5q5fzigaJpZM4Kk21N .

coderaiser commented 7 years ago

Ill have a look at clean-css and how it deals with images.

It is not about clean-css, base64 encoding made by css-base64-images.

rynomster commented 7 years ago

I see in css-base64-images there is a 4kb limit. I've just checked the version numbers, I'm running 2.0.11 on my linux machine and 2.0.12 on my macbook.. Linux is outputting the normal image uris, where the macbook is outputting the base64 encoded... I'll have a look at maybe adding a flag to allow you to not base64 encode images for those that don't need it.

Thanks again :)