Hello everyone,
I’m struggling with precompiling assets both on Heroku and locally when the environment is set to production.
I have a manifest file, ./app/assets/javascripts/application.js which includes another file, located at ./vendor/assets/javascripts/fullcalendar/dist/fullcalendar.js as follows:
//= require fullcalendar/dist/fullcalendar
This works just fine when I run a local server in development mode. I noticed something is off when I pushed to Heroku, which won’t precompile my assets:
remote: Running: rake assets:precompile
remote: rake aborted!
remote: Sprockets::FileNotFound: couldn’t find file ‘fullcalendar/dist/fullcalendar’ with type ‘application/javascript’
So I tried precompiling assets locally, which works as expected when the environment is set to development. However, when I run …
% RAILS_ENV=production bundle exec rake assets:precompile --trace
… ExecJS yells at me (full trace here):
** Execute assets:precompile
rake aborted!
ExecJS::ProgramError: Unexpected token punc «(», expected punc «:» (line: 70927, col: 13, pos: 2134177)
I have no idea what’s wrong or how to debug this, because all of my own JavaScript gets tested, linted and passes just fine. My application doesn’t throw errors in browsers either. I assume one of my dependencies uses ES6 method definitions?
Those are my asset paths:
./app/assets/images ./app/assets/javascripts ./app/assets/stylesheets ./vendor/assets/bower_components ./vendor/assets/javascripts ./vendor/assets/stylesheets
And the only change I made in ./config/initializers/assets.rb is adding another manifest file for precompilation:
Rails.application.config.assets.precompile += %w(onboarding.js)
So to sum up my two questions:
- How do I properly include files located at /vendor/assets/**/* in manifest files?
- What’s ExecJS executing at precompilation and how do I figure what breaks it?
Thanks in advance!