Search code examples
ruby-on-railsprecompiled

RoR Precompiling Assets fail while rake assets:precompile - on basically empty application.js


Running:

bundle exec rake assets:precompile RAILS_ENV=production --trace

** Execute assets:precompile:primary
rake aborted!
TypeError: Object doesn't support this property or method
  (in C:/Sites/MyApp/app/assets/javascripts/application.js)

Here is the entire content of application.js:

//= require jquery
//= require jquery_ujs
//= require_tree .

nothing else there.

I tried to remove the three //= require lines from application.js, the precompilation then runs with no problems.


Solution

  • Looks like it might be a problem with uglifier and Windows Script Host:

    https://github.com/rails/rails/issues/2847

    Make sure you're using the last version of uglifier (1.0.4). If you're still having problems, I'd suggest trying a different compiler (e.g. Closure compiler)

    In Gemfile:

    gem 'closure-compiler'
    

    In config/environments/production.rb

    config.assets.js_compressor = :closure
    

    alternatively disable JS compression altogether:

    config.assets.compress = false