Rails凉亭不会编译

时间:2014-09-11 18:18:10

标签: ruby-on-rails ruby ruby-on-rails-4 assets bower

我的导轨解决方案使用Bower来管理我的前端库。 我按照this tutorial设置了它。 它正在工作,但是当我尝试预编译时,会出现以下错误:

RAILS_ENV=production bundle exec rake assets:precompile
rake aborted!
ExecJS::ProgramError: Unexpected token: eof (undefined) (line: 46, col: 0, pos: 1406)

Error
    at new JS_Parse_Error (/tmp/execjs20140911-20410-llghcjjs:2357:10623)
    at js_error (/tmp/execjs20140911-20410-llghcjjs:2357:10842)
    at croak (/tmp/execjs20140911-20410-llghcjjs:2357:19067)
    at token_error (/tmp/execjs20140911-20410-llghcjjs:2357:19204)
    at unexpected (/tmp/execjs20140911-20410-llghcjjs:2357:19292)
    at block_ (/tmp/execjs20140911-20410-llghcjjs:2357:24537)
    at ctor.body (/tmp/execjs20140911-20410-llghcjjs:2357:24191)
    at function_ (/tmp/execjs20140911-20410-llghcjjs:2357:24256)
    at expr_atom (/tmp/execjs20140911-20410-llghcjjs:2357:27308)
    at maybe_unary (/tmp/execjs20140911-20410-llghcjjs:2357:29977)
  (in /home/augustopedraza/Documents/Projects/BuscoHogar/landing-page/vendor/assets/bower_components/jquery/src/intro.js)

知道怎么解决吗?

提前致谢!!!

2 个答案:

答案 0 :(得分:1)

我遇到了同样的问题..我发现这是因为资产的压缩一般。所以临时修复会在config / environments / production.rb中评论这一行:

config.assets.js_compressor = :uglifier

我目前还不知道uglifier本身在压缩JS文件后是否会导致错误,或者JS是否有错误。我目前正在探索js压缩的其他替代方案,看看它是否有效.P.S。我也使用了凉亭组件,所以bower + uglifier可能导致错误

答案 1 :(得分:-1)

我能够通过编辑文件intro.js来解决这个问题。产生错误的行是:

 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ){

将其更改为

}(typeof window !== "undefined" ? window : this, function( window, noGlobal ){}));

您现在可能会收到outro.js的错误,该错误仅包含缺失的

}));

只需将其删除即可编译。我还没有对它进行过广泛的测试,但由于这些变化,我还没有发现任何关于jquery破坏的事情。