Skip to content
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

Inline images into application.css during asset compilation #143

Merged
merged 4 commits into from
Sep 4, 2024

Conversation

amatsuda
Copy link
Member

@amatsuda amatsuda commented Sep 3, 2024

This patch adds a Sprockets processor that in-lines images into the compiled CSS file.

The inline asset mode implemented at #107 generates a single HTML file that inlines all the assets, but indeed it still misses one thing, i.e. images referenced from inside .css files.

That problem has already been addressed by @AMHOL via #113, so I extracted the Sprockets processor proc from that PR, leaving the credit as a co-author on @AMHOL.

Since this hack is based on SassProcessor mechanism, we had to switch the whole CSS processing and compressing from yui-compressor to sass. I know that Ruby implementation of sass gem is no longer actively developed, but it seems to work here so far.

amatsuda and others added 4 commits September 4, 2024 00:53
This proc changes `url()` calls in *.css
e.g.) background-image: url("DataTables-1.10.20/images/sort_both.png");
into base64 encoded inline image via `rake assets:compile`.

Note that all images referenced in CSS will be loaded this way, whether
or not the user enables SIMPLECOV_INLINE_ASSETS option.

This idea and code is taken from
simplecov-ruby#113 by @AMHOL

Co-authored-by: AMHOL <andyholland1991@aol.com>
@amatsuda amatsuda merged commit c225a83 into simplecov-ruby:main Sep 4, 2024
11 checks passed
@amatsuda amatsuda deleted the inline_css_assets branch September 4, 2024 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant