19

My minimal app runs locally and I have no bundle errors. When I push to heroku, however, the build fails during assets:precompile step:

...
Bundle completed (3.24s)
Cleaning up the bundler cache.
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompole
rake aborted!
LoadError: cannot load such file -- uglifier
(in /tmp/build_.../app/assets/javascripts/application.js)

Notes:
1. I am not using the uglifier gem locally
2. I do not have a file app/assets/javascripts/application.js

I have tried these Gemfile solutions:
A) adding the uglifier gem
B) adding uglifier to the assets group
C) removing uglifier completely from Gemfile and rake uninstall all versions

What's next?

Jai Chauhan
  • 4,035
  • 3
  • 36
  • 62
vbsql7
  • 684
  • 2
  • 9
  • 17
  • You don't want to use the asset pipeline at all? – Sander Garretsen Dec 26 '14 at 17:06
  • check if you have javascript error on the browser console. Try precompile on local machine. – pkrawat1 Dec 26 '14 at 17:13
  • The precompile locally works except for pg_ext, which seems to be a different issue than uglifier. What I don't understand is why uglifier is being referenced at all since I removed it from the Gemfile and uninstalled all versions?? – vbsql7 Dec 26 '14 at 17:47

4 Answers4

19

A better solution, if you want to compress your assets, is to add uglifier to your GEMFILE:

gem 'uglifier'

mindtonic
  • 1,385
  • 2
  • 14
  • 24
14

Comment this line in config/environments/production.rb

config.assets.js_compressor = :uglifier
pkrawat1
  • 671
  • 7
  • 18
6

If you're interested in continuing to use uglifier, you can add it to your Gemfile (and install with Bundler) -- as explained by @mindtonic.

Also, if you're using ES6, you'll need to switch:

config.assets.js_compressor = :uglifier

to:

config.assets.js_compressor = Uglifier.new(harmony: true)

As explained in https://github.com/lautis/uglifier/issues/127

mudphone
  • 956
  • 10
  • 9
1

You have to focus on two points:

Point 1. Version of the Gem: This should be 4.2

gem 'uglifier', '~> 4.2'

Point 2. Use js compressor now

config.assets.js_compressor = Uglifier.new(harmony: true)
Dharman
  • 30,962
  • 25
  • 85
  • 135
Jai Chauhan
  • 4,035
  • 3
  • 36
  • 62