Precompiling assets failed after adding action text

I tried adding action text by following this: https://stackoverflow.com/a/55983943.

Everything worked fine in development.

But when I try to push it to heroku by running git push heroku, I get this error:

remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !   Push rejected to sampleapp.
remote:
remote:
To https://git.heroku.com/sampleapp.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/sampleapp.git'

I tried adding

config.assets.initialize_on_precompile = false

to config/application.rb but it didn't work

Its already added to config/environments/production.rb.

I tried running RAILS_ENV=production bundle exec rake assets:precompile but it gave me this error:

ExecJS::RuntimeError: SyntaxError: Unexpected token: string (actiontext)
JS_Parse_Error.get ((execjs):3538:621)

So, how do I resolve this error?

Upvotes: 0

Views: 136

Answers (1)

This probably sounds dumb but I solved the problem now.

What worked was changing

config.assets.js_compressor = :uglifier

in config/environments/production.rb to

config.assets.js_compressor = Uglifier.new(harmony: true)

Upvotes: 0

Related Questions