From fb362ef0d8e457cdc49b43f251f2a71eca8ef509 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 5 Jul 2022 18:41:42 +0100 Subject: [PATCH] Enable brotli compression for assets --- Gemfile | 3 +++ Gemfile.lock | 5 +++++ config/initializers/brotli.rb | 3 +++ 3 files changed, 11 insertions(+) create mode 100644 config/initializers/brotli.rb diff --git a/Gemfile b/Gemfile index 65ee29d58..1b2b60864 100644 --- a/Gemfile +++ b/Gemfile @@ -36,6 +36,9 @@ gem "image_optim_rails" # Use argon2 for password hashing gem "argon2" +# Support brotli compression for assets +gem "sprockets-exporters_pack" + # Load rails plugins gem "actionpack-page_caching", ">= 1.2.0" gem "activerecord-import" diff --git a/Gemfile.lock b/Gemfile.lock index 0d0587ad9..d2d443eb6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -125,6 +125,7 @@ GEM actionpack (>= 5.2) activemodel (>= 5.2) brakeman (5.2.3) + brotli (0.4.0) browser (5.3.1) builder (3.2.4) bzip2-ffi (1.1.0) @@ -476,6 +477,9 @@ GEM sprockets (4.1.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) + sprockets-exporters_pack (0.1.2) + brotli (>= 0.2.0) + sprockets (>= 4.0.0.beta3) sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) @@ -590,6 +594,7 @@ DEPENDENCIES selenium-webdriver simplecov simplecov-lcov + sprockets-exporters_pack strong_migrations terser validates_email_format_of (>= 1.5.1) diff --git a/config/initializers/brotli.rb b/config/initializers/brotli.rb new file mode 100644 index 000000000..9e8125b14 --- /dev/null +++ b/config/initializers/brotli.rb @@ -0,0 +1,3 @@ +Rails.application.config.assets.configure do |env| + env.register_exporter %w[text/* application/javascript application/json application/xml image/x-icon image/svg+xml], Sprockets::ExportersPack::BrotliExporter +end -- 2.39.5