-
Notifications
You must be signed in to change notification settings - Fork 109
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
Integration with Rails asset pipeline as sprocket preprocessor #2
Comments
|
Hi, guys, I really like the idea of replacing the core of sprockets-image_compressor with image_optim, but there would be one big regression: Image_optim won't currently work on Heroku because they don't have the binaries installed on their servers. I've statically compiled Heroku-friendly pngcrush and jpegoptim binaries and vendored them into sprockets-image_compressor to get around this issue. @toy, what are the odds of something similar happening here? P.S. I'm running sprockets-image_compressor on deployment on about a dozen sites, and while not blazing fast, the overall asset compilation speed is acceptable. |
It may be a better idea to create separate gem with statically compiled binaries per platform and setting default_bin for each worker, otherwise image_optim will be a heavy gem. There is a problem with pngout as it can not be redistributed «without consent and agreement of creator». |
@botandrose: just to be sure that you read previous one |
Thanks guys. Good discussion and nice points. Not sure what the outvome will be but hopefully someone wilvome up with an even better solution integrating all these nice solutions while still ensuring good performance etc. |
Guys, while your thrilling effort doesn't take off, how do you suggest setting up a nice integration of image_optim with a production rails app ? What about not running every time during deploy as an asset preprocessor, but maybe every time AFTER deploy ? So deploy doesn't take forever and you leave the script running after deploy is finished ? |
For those that came here after googling (like me). |
Creating sprocket preprocessor appeared to be very simple, checkout rails branch, especially: https://github.com/toy/image_optim/blob/rails/lib/image_optim/railtie.rb |
Cool 👍 |
@mooktakim I've finally managed to create bin pack for |
Hey @toy, |
Hey @toy |
@ghostropic |
@toy Sorry for the confusion. |
@ghostropic Ah no, I understood you, but my questions were confusing. As I understand heroku gives you ubuntu servers and |
@ghostropic As there was already a heroku app to check versions, I've added there a very basic upload with optimisation for checking if everything works, and it seems it does: https://iopack.herokuapp.com/ |
Check out this article :)
http://psionides.eu/2012/05/06/extending-asset-pipeline-with-custom-preprocessors/
The context is an instance of Sprockets::Context; you can use it to e.g. read the current file’s path or content type, generate paths to asset files or access asset pipeline configuration. You also have access to several asset helpers from ActionView, like javascript_include_tag, image_tag etc.
http://rubydoc.info/gems/sprockets/2.0.3/Sprockets/Context
I think you would need fx
content_type
and somehow access the full path of the asset and run it through image_optim.Just found an example here: https://github.com/botandrose/sprockets-image_compressor
Maybe you could join forces ;)
Sweet and simple! Yeah :)
The text was updated successfully, but these errors were encountered: