Skip to content

Commit

Permalink
fix failing assets:precompile step
Browse files Browse the repository at this point in the history
Deploying fails on the `assets:precompile` step with:
```
Uglifier::Error:  (Uglifier::Error)
/uglifier.rb:291:in `parse_result'
```

Issue here: lautis/uglifier#185

There's a workaround suggested in the issue, but it's also suggested to move to the [Terser gem](https://github.com/ahorek/terser-ruby) as Uglifier's last update was more than 5 years ago, and Terser's is 3 weeks ago.

This moves to the Terser gem.
  • Loading branch information
jxjj committed Apr 23, 2024
1 parent 0d23a9a commit 8a7ad2d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,5 @@ gem 'browser', "~> 4.2"
gem "rack-utf8_sanitizer", "~> 1.7"

# gem "tailwindcss-rails", "~> 2.0"

gem "terser", "~> 1.2"
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ GEM
net-sftp (>= 2.1.2)
net-ssh (>= 2.8.0)
stringio (3.1.0)
terser (1.2.2)
execjs (>= 0.3.0, < 3)
thor (1.3.1)
tilt (2.3.0)
timeout (0.4.1)
Expand Down Expand Up @@ -602,6 +604,7 @@ DEPENDENCIES
sprockets-rails
sqlite3 (~> 1.4)
starburst!
terser (~> 1.2)
turbolinks (~> 5.2)
twitter-bootstrap-rails!
twitter-typeahead-rails!
Expand Down
5 changes: 3 additions & 2 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
# config.require_master_key = true

# Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
# config.public_file_server.enabled = false
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

# Compress JS assets. Needed for Sprockets
config.assets.js_compressor = Uglifier.new(harmony: true)
# config.assets.js_compressor = Uglifier.new(harmony: true)
config.assets.js_compressor = :terser

# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass
Expand Down
5 changes: 3 additions & 2 deletions config/environments/remotedev.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

# Compress JavaScripts and CSS.
config.assets.js_compressor = Uglifier.new(harmony: true)
config.assets.js_compressor = :terser

# config.assets.css_compressor = :sass

# Do not fallback to assets pipeline if a precompiled asset is missed.
Expand Down Expand Up @@ -71,7 +72,7 @@
config.active_support.deprecation = :notify

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
config.log_formatter = Logger::Formatter.new

# Use a different logger for distributed setups.
# require 'syslog/logger'
Expand Down
5 changes: 3 additions & 2 deletions config/environments/staging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

# Compress JavaScripts and CSS.
config.assets.js_compressor = Uglifier.new(harmony: true)
config.assets.js_compressor = :terser

# config.assets.css_compressor = :sass

# Do not fallback to assets pipeline if a precompiled asset is missed.
Expand Down Expand Up @@ -71,7 +72,7 @@
config.active_support.deprecation = :notify

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
config.log_formatter = Logger::Formatter.new

# Use a different logger for distributed setups.
# require 'syslog/logger'
Expand Down

0 comments on commit 8a7ad2d

Please sign in to comment.