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 integrate
- Rails 3.1
- Jquery calendar: https://github.com/themouette/jquery-week-calendar
- Twitter bootstrap
The error happens from uglifier.
I suspect that problem could be related to the inclusion of many localizations for the calendar.
I worked around the error by setting:
# Compress JavaScripts and CSS
config.assets.compress = false
I was not able to examine the files as the temporary files are cleaned up. I also could not get the debugger in RubyMine to stop at a breakpoint.
Any ideas if this is a bug? Any way to get the temporary files to not get deleted? Any way to make the RubyMine debugger work on the rake task (yes, tried the obvious, using EAP 112-291.
rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets rake aborted! Unexpected character '' (line: 21454, col: 0, pos: 641761)
Error at new JS_Parse_Error (/tmp/execjs20111231-15374-1fve7h4.js:497:22) at js_error (/tmp/execjs20111231-15374-1fve7h4.js:505:15) at parse_error (/tmp/execjs20111231-15374-1fve7h4.js:596:17) at Object.next_token [as input] (/tmp/execjs20111231-15374-1fve7h4.js:839:17) at next (/tmp/execjs20111231-15374-1fve7h4.js:943:37) at Object.semicolon [as 1] (/tmp/execjs20111231-15374-1fve7h4.js:986:38) at prog1 (/tmp/execjs20111231-15374-1fve7h4.js:1527:28) at simple_statement (/tmp/execjs20111231-15374-1fve7h4.js:1123:35) at /tmp/execjs20111231-15374-1fve7h4.js:1031:35 at /tmp/execjs20111231-15374-1fve7h4.js:1510:32
You will probably find that one of you js files has a syntax error somewhere. This could be a missing semicolon at the end of a block, or some other minor problem. Often browsers will still load the js and it will work, but uglifier cannot compress it with those errors. I would start looking in the localisation files first.
One way to find out which file contains the error is to re precompile locally with a minimal set of files and add things one by one until it breaks. If it is due to a missing semicolon, the breakage will the second-last file you added.
Mine precompiled after I removed a stray "debugger" statement. Woops.
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.)
The I18N file "jquery-ui-i18n.js" has a bad character before each comment.
Looking at the first two lines with "more" in a shell, shows the wrong character:
<U+FEFF>/* Afrikaans initialisation for the jQuery UI date picker plugin. */
/* Written by Renier Pretorius. */
After having removed this character it works.
来源:https://stackoverflow.com/questions/8692666/rails-3-1-possible-bug-in-asset-pipeline-and-uglifier