vbsql7
vbsql7

Reputation: 704

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?

Upvotes: 19

Views: 4729

Answers (4)

Jai Kumar Rajput
Jai Kumar Rajput

Reputation: 4217

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)

Upvotes: 1

mudphone
mudphone

Reputation: 946

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

Upvotes: 6

mindtonic
mindtonic

Reputation: 1395

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

gem 'uglifier'

Upvotes: 19

pkrawat1
pkrawat1

Reputation: 681

Comment this line in config/environments/production.rb

config.assets.js_compressor = :uglifier

Upvotes: 14

Related Questions