Skip to content

Commit

Permalink
use terser
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickpatrickpatrick committed Nov 13, 2023
1 parent 021f810 commit 02397bb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ gem "rss"
gem "sassc-rails"
gem "slimmer"
gem "sprockets-rails"
gem "uglifier"
gem "terser"

group :development, :test do
gem "govuk_schemas"
Expand Down
4 changes: 1 addition & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,6 @@ GEM
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
Expand Down Expand Up @@ -656,8 +654,8 @@ DEPENDENCIES
simplecov
slimmer
sprockets-rails
terser
timecop
uglifier
webmock

RUBY VERSION
Expand Down
17 changes: 17 additions & 0 deletions config/initializers/sprockets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This adds terser as a recognised compressor
# to Sprockets. Without this patch, Sprockets
# will not be able to run terser.
#
# Code originates from:
# https://stackoverflow.com/a/70086366

require "terser"

module Sprockets
class Environment < Base
def js_compressor=(compressor)
register_compressor "application/javascript", :terser, Terser::Compressor
super
end
end
end

0 comments on commit 02397bb

Please sign in to comment.