“rake assets:precompile” gives punc error

前端 未结 10 716
离开以前
离开以前 2020-12-04 10:56

I\'m trying to precompile my assets for production, but rails doesn\'t seem to be cooperating.

$ bundle exec rake assets:precompile
/home/drderp/.rvm/rubies/         


        
10条回答
  •  感情败类
    2020-12-04 11:19

    This was horrible; no javascript error on my local computer means that there's an issue with asset compilation.

    Here's how I solved it.

    As suggested in the comments for a similar question ExecJS::ProgramError: Unexpected token punc «(», expected punc «:» when running rake assets:precompile on production , I removed uglifier (in production.rb, comment out the compressor line) and compression altogether. (I had tried with other compressors; yui did not give much information. closure seemed to give me a hint but didn't help much)

    I then compressed the assets locally, then I pushed to production. (To compress locally, use RAILS_ENV=production rake assets:precompile )

    I ran on the server and this is when the javascript errors surfaced. It was basically erroneous merging of files (mainly due to something commented out). I got rid of those lines and pushed back to production. Everything succeeded.

    I brought back uglifier, deleted the precompiled assets under public/assets/ and pushed back to production.

    I hope this helps someone!

提交回复
热议问题