In order to debug javascript in my heroku production environment, I need to disable asset compression (or at least compression of javascript). I tried config.assets.c
Comment out the uglifier and add config.assets.debug = true
. This worked for me.
Compress JavaScripts and CSS:
config.assets.js_compressor = :uglifier
Debug mode disables concatenation and preprocessing of assets. But this option may cause significant delays in view rendering with a large number of complex assets:
config.assets.debug = true
Find and comment out these line in environments/production.rb
:
config.assets.js_compressor = ...
config.assets.css_compressor = ...
I came up with this workaround after reading the docs:
create a module that does nothing to compress js / css here: lib/modules/no_compression.rb
class NoCompression
def compress(string)
# do nothing
string
end
end
configure your assets to (not) be compressed with your do-nothing compressor
config.assets.compress = true
config.assets.js_compressor = NoCompression.new
config.assets.css_compressor = NoCompression.new
I also need to debug my js so I tried ncherro's solution. The problem was that it would still throw
rake aborted! uninitialized constant NoCompression
So I just put the NoCompression class in the production.rb file
# Compress JavaScripts and CSS
class NoCompression
def compress(string)
# do nothing
string
end
end
config.assets.compress = true
config.assets.js_compressor = NoCompression.new
config.assets.css_compressor = NoCompression.new
Also worth noting... In addition to ncherro solution you will need to do the following:
rake assets:clean
to clean your existing assets.rake assets:precompile
to compile your assets using the new compressor.touch tmp/restart.txt
Happy debugging ;)
With Rails 4 on Heroku you need to do two things. First as @geekQ mentioned, comment out the js_compressor line in config/environments/production.rb
# config.assets.js_compressor = :uglifier
Second, you need to consider Heroku's asset pipeline cache for Rails 4. Any file with the same MD5 as the version in the cache will not be recompiled. The previous (possibly compressed) version will be served. Any file you edit will have a new MD5 and be recompiled.
You can also purge the entire asset cache with the Heroku Repo plugin to the Heroku toolbelt. Install that, then use the command
heroku repo:purge_cache
Deploy a new version after purging the cache and all your assets will be recompiled.