Skip to content

Commit

Permalink
Merge pull request #143 from amatsuda/inline_css_assets
Browse files Browse the repository at this point in the history
Inline images into application.css during asset compilation
  • Loading branch information
amatsuda authored Sep 4, 2024
2 parents e0ebe4c + 2c44778 commit c225a83
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ group :development do
gem "rubocop-minitest"
gem "rubocop-performance"
gem "rubocop-rake"
gem "sass"
gem "sprockets"
gem "uglifier"
gem "yui-compressor"
end

gem "base64" if RUBY_VERSION >= "3.3"
Expand Down
21 changes: 15 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/simplecov-ruby/simplecov
revision: 0260b1f309e76c8ed87731ebbc348b05d753b8a2
revision: b6c2d4208a5fa395ce09d7e1d3b074f680ee29b0
specs:
simplecov (0.22.0)
docile (~> 1.1)
Expand All @@ -16,9 +16,12 @@ GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
base64 (0.2.0)
concurrent-ruby (1.3.4)
docile (1.4.1)
execjs (2.9.1)
ffi (1.17.0)
logger (1.6.1)
minitest (5.15.0)
parallel (1.24.0)
parser (3.3.4.2)
Expand All @@ -29,9 +32,11 @@ GEM
rack (3.1.7)
rainbow (3.1.1)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
regexp_parser (2.9.2)
rexml (3.3.6)
strscan
rubocop (1.28.2)
parallel (~> 1.10)
parser (>= 3.1.0.0)
Expand All @@ -51,34 +56,38 @@ GEM
rubocop-rake (0.6.0)
rubocop (~> 1.0)
ruby-progressbar (1.13.0)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
simplecov_json_formatter (0.1.4)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
strscan (3.1.0)
strscan (3.1.0-java)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (2.5.0)
yui-compressor (0.12.0)

PLATFORMS
arm64-darwin-22
ruby
universal-java-1.8

DEPENDENCIES
base64
logger
minitest
rake (>= 11)
rubocop
rubocop-minitest
rubocop-performance
rubocop-rake
sass
simplecov!
simplecov-html!
sprockets
uglifier
yui-compressor

BUNDLED WITH
2.3.15
11 changes: 10 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,20 @@ namespace :assets do
task :compile do
puts "Compiling assets"
require "sprockets"
require "sprockets/sass_processor"

Sprockets.register_processor("text/css") do |input|
{data: input[:data].gsub(/(?<!-|_)url\(['"]?(.+?)['"]?\)/) { "asset-data-url(\"#{Regexp.last_match(1)}\")" }}
end

Sprockets.register_processor "text/css", Sprockets::ScssProcessor

assets = Sprockets::Environment.new do |env|
env.append_path "assets/javascripts"
env.append_path "assets/stylesheets"
env.append_path "public"
env.js_compressor = :uglify
env.css_compressor = :yui
env.css_compressor = :scss
end
assets["application.js"].write_to("public/application.js")
assets["application.css"].write_to("public/application.css")
Expand Down
2 changes: 1 addition & 1 deletion assets/stylesheets/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ abbr.timeago {
}

a.src_link {
background: url("./magnify.png") no-repeat left 50%;
background: url("magnify.png") no-repeat left 50%;
padding-left: 18px;
}

Expand Down
2 changes: 1 addition & 1 deletion public/application.css

Large diffs are not rendered by default.

0 comments on commit c225a83

Please sign in to comment.