Enable Uglifier verbose logging in Sprockets-Rails

653 Views Asked by At

I have a Rails project where a newly added javascript file (plotly.min.js) is causing rake assets:precompile to hang indefinitely in production mode only. Since the problem is related to javascript compression, I would like to enable verbose logging for Uglifier. I can see that this is possible for the UgligyJS2 command line tool, but my question is how to enable this from my Rails app, preferable in an initializer or the like. I can solve the issue by changing my javascript compressor to closure-compiler, but I would like to identify the problem with uglifier.

2

There are 2 best solutions below

3
On

You need to override the sprockets logger in the initializer:

if Rails.env.production?
  Rails.application.assets.logger = Logger.new($stdout)

  # This sets the log level to debug
  Rails.application.assets.logger.level = 0
end
1
On

Sadly I don't have a proper answer to this problem either (I solved it for now by disabling the uglifier in production):

# Compress JavaScripts and CSS.
# KT TODO: reenable js compression
# config.assets.js_compressor = :uglifier

... but just to confirm that I ran into the same problem with uglifier and plotly.js.