Skip to content

Commit 3399297

Browse files
committed
Move image_optim to the docs bundle group
Only the scrapers optimize images since the spritesheets went through cwebp, so the app installed five megabytes of binaries it never ran.
1 parent e23469c commit 3399297

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎Gemfile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ group :app do
1313
gem 'chunky_png'
1414
gem 'erubi'
1515
gem 'dartsass-sprockets'
16-
gem 'image_optim_pack', platforms: :ruby
17-
gem 'image_optim'
1816
gem 'puma'
1917
gem 'rack'
2018
gem 'rss'
@@ -35,6 +33,8 @@ group :development do
3533
end
3634

3735
group :docs do
36+
gem 'image_optim_pack', platforms: :ruby
37+
gem 'image_optim'
3838
gem 'kramdown'
3939
gem 'kramdown-parser-gfm'
4040
gem 'redcarpet'

‎lib/docs/filters/core/images.rb‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# frozen_string_literal: true
22

33
require 'base64'
4-
require 'image_optim'
54

65
module Docs
76
class ImagesFilter < Filter
@@ -21,6 +20,9 @@ class ImagesFilter < Filter
2120
CWEBP_LOSSY_COMMAND = %W(cwebp -quiet -q #{JPEG_QUALITY} -m 6 -sharp_yuv -metadata none -o - -- -).freeze
2221
GIF2WEBP_COMMAND = %w(gif2webp -quiet -m 6 -metadata none -o - -- -).freeze
2322

23+
# image_optim belongs to the docs bundle group, which the app leaves out;
24+
# `Bundler.require :default, :docs` in docs.rb loads it for the scrapers,
25+
# which are the only ones optimizing anything.
2426
def self.optimize_image_data(data)
2527
@image_optim ||= ImageOptim.new
2628
@image_optim.optimize_image_data(data)

0 commit comments

Comments
 (0)