windows – rake资产:预编译不起作用(rails 3.1.1)

我正在部署到heroku但我看到没有提供css文件(它们也无法在heroku上找到).

我读到我需要做rake资产:首先在本地预编译然后当我这样做时,我得到:

C:\project>bundle exec rake assets:precompile --trace

** Invoke assets:precompile (first_time)
** Execute assets:precompile
rake aborted!
undefined: Unexpected token: operator (<)
  (in C:/project/app/assets/javascripts/application.js)

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

我在application.js中什么也没有,所以我不明白错误在哪里..

application.js是

// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here,but if you do,it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require_tree .

谢谢

更新

如果删除.js.erb文件,我会收到以下错误

C:\project>bundle exec rake assets:precompile RAILS_ENV=production --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
rake aborted!
706: unexpected token at 'C:\Users\me\AppData\Local\Temp\execjs20111021-6448-ei2nm3.js(2,3) Microsoft JScript runtime error: Out of memory

'
  (in C:/project/app/assets/javascripts/application.js)

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

仍然有erb css和js文件没有编译的问题…

这似乎没有结束..
谢谢

我认为它是由外部javascript文件引起的,这个文件没有良好的代码格式.例如
function say_hi(){
  // NOTICE that there's no semi-colon there!
  name = "Jim"
  alert("hi" + name )
}

在预编译下,你的代码将放入1行,并且因为没有必要的分号,你生成的js文件可能包含错误,比如

"undefined: Unexpected token: operator (<)"

或者其他的东西.

所以,我的建议是:

>如果js文件的代码格式不正确,请不要压缩js文件,方法是在配置文件中设置“config.assets.compress = false”,然后按@ Mike的回答.>尽可能使用coffeescript,它将帮助您生成格式良好的代码. (我不是coffeescript大师,所以如果我错了请纠正我)

相关文章

文章浏览阅读2.2k次,点赞6次,收藏20次。在我们平时办公工作...
文章浏览阅读1k次。解决 Windows make command not found 和...
文章浏览阅读3.2k次,点赞2次,收藏6次。2、鼠标依次点击“计...
文章浏览阅读1.3w次。蓝光版属于高清版的一种。BD英文全名是...
文章浏览阅读974次,点赞7次,收藏8次。提供了更强大的功能,...
文章浏览阅读1.4w次,点赞5次,收藏22次。如果使用iterator的...