From ba439f7534614b4c9cf2cb826b3e3987e5c97abf Mon Sep 17 00:00:00 2001 From: Julian Rubisch Date: Tue, 2 Jan 2024 18:34:21 +0100 Subject: [PATCH] feat: Add terser for js compression in production (#1249) --- Gemfile | 2 ++ Gemfile.lock | 4 ++++ config/environments/production.rb | 3 +++ 3 files changed, 9 insertions(+) diff --git a/Gemfile b/Gemfile index 9a5bee0f0..90c40add2 100644 --- a/Gemfile +++ b/Gemfile @@ -194,6 +194,8 @@ group :production do # Use S3 for Active Storage by default. gem "aws-sdk-s3", require: false + + gem "terser" end # Use Ruby hashes as readonly datasources for ActiveRecord-like models. diff --git a/Gemfile.lock b/Gemfile.lock index 1e00fe0cb..ac76a267e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -296,6 +296,7 @@ GEM erubi (1.12.0) erubis (2.7.0) event_stream_parser (1.0.0) + execjs (2.9.1) extended_email_reply_parser (0.5.1) activesupport charlock_holmes @@ -644,6 +645,8 @@ GEM railties (>= 6.0.0) stringio (3.1.0) stripe (10.2.0) + terser (1.1.20) + execjs (>= 0.3.0, < 3) thor (1.3.0) thread-local (1.1.0) timeout (0.4.1) @@ -755,6 +758,7 @@ DEPENDENCIES sprockets-rails standard stimulus-rails + terser turbo-rails tzinfo-data web-console diff --git a/config/environments/production.rb b/config/environments/production.rb index 6e9c3a052..01fb28e28 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -32,6 +32,9 @@ # Compress CSS using a preprocessor. # config.assets.css_compressor = :sass + # Compress JavaScript + config.assets.js_compressor = :terser + # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false