Rails 3.1 Possible Bug in Asset Pipeline and Uglifier

前端 未结 4 1885
借酒劲吻你
借酒劲吻你 2021-01-19 20:03

I ran into a problem deploying on Heroku do to a failure in the rake task

rake assets:precompile

At the bottom is the error I get if I inte

4条回答
  •  半阙折子戏
    2021-01-19 20:19

    If anyone reading this thread encounters issues with unicode characters or "invalid byte sequence in UTF-8" in your rails app, try putting this in your production.rb file:

    # override default uglifier options so we don't mangle unicode
      config.assets.js_compressor = Uglifier.new(output: {ascii_only: true})
    

    In my case, the uglifier was converting strings in my javascript like \udbff into UTF-8 characters í¯¿ which ultimately was breaking some unicode regex. (This was happening with turbo-sprockets and codemirror but you might encounter it anytime your javascript relies on ASCII representations of unicode characters.)

提交回复
热议问题