Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku build fails on uglifier

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?

like image 423
vbsql7 Avatar asked Dec 26 '14 16:12

vbsql7


4 Answers

Comment this line in config/environments/production.rb

config.assets.js_compressor = :uglifier
like image 29
pkrawat1 Avatar answered Nov 10 '22 22:11

pkrawat1


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

gem 'uglifier'

like image 141
mindtonic Avatar answered Nov 10 '22 21:11

mindtonic


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

like image 6
mudphone Avatar answered Nov 10 '22 22:11

mudphone


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)
like image 1
Jai Kumar Rajput Avatar answered Nov 10 '22 22:11

Jai Kumar Rajput