From 776996501cfed2b94cc5ab9594ce1be59b0701a4 Mon Sep 17 00:00:00 2001 From: Marco Tranchino Date: Tue, 17 Sep 2024 11:45:43 +0100 Subject: [PATCH] Use `terser` for Javascript minification This is needed because of the need to create two different JS rollups and because the default compressor fails. See link below. https://github.com/alphagov/tech-docs-gem/issues/352#issuecomment-2352404262 --- Gemfile | 2 ++ example/Gemfile | 2 ++ lib/govuk_tech_docs.rb | 1 + 3 files changed, 5 insertions(+) diff --git a/Gemfile b/Gemfile index e3c78d49..8cbb8467 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,5 @@ source "https://rubygems.org" # Specify your gem's dependencies in govuk_tech_docs.gemspec gemspec + +gem "terser" \ No newline at end of file diff --git a/example/Gemfile b/example/Gemfile index 0d4908e1..d4b4869f 100644 --- a/example/Gemfile +++ b/example/Gemfile @@ -1,3 +1,5 @@ source "https://rubygems.org" gem "govuk_tech_docs", path: ".." + +gem "terser" diff --git a/lib/govuk_tech_docs.rb b/lib/govuk_tech_docs.rb index cf5733ac..8f066cae 100644 --- a/lib/govuk_tech_docs.rb +++ b/lib/govuk_tech_docs.rb @@ -57,6 +57,7 @@ def self.configure(context, options = {}) context.configure :build do activate :autoprefixer + activate :minify_javascript, compressor: Terser.new # activate :minify_javascript, ignore: ["/raw_assets/*"] end