加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

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

发布时间:2020-12-14 04:18:16 所属栏目:Windows 来源:网络整理
导读:我正在部署到heroku但我看到没有提供css文件(它们也无法在heroku上找到). 我读到我需要做rake资产:首先在本地预编译然后当我这样做时,我得到: C:projectbundle exec rake assets:precompile --trace** Invoke assets:precompile (first_time)** Execute a
我正在部署到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:UsersmeAppDataLocalTempexecjs20111021-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大师,所以如果我错了请纠正我)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读