ruby-on-rails-3.1 – 资产管道不压缩javascript到application.j
发布时间:2020-12-16 20:11:44 所属栏目:百科 来源:网络整理
导读:我有两个问题. 我错误地假设我的所有JavaScript应该被压缩到application.js默认情况下在rails 3.1甚至在开发模式? 如果没有,那么为什么我的标签有我所有的30个我的javascripts,并承担加载? 我的application.js文件如下所示: //= require jquery//= requir
我有两个问题.
>我错误地假设我的所有JavaScript应该被压缩到application.js默认情况下在rails 3.1甚至在开发模式? 我的application.js文件如下所示: //= require jquery //= require jquery_ujs //= require jquery-ui //= require_tree . 在浏览器中,它被渲染为: // 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. // ; 虽然我所有的其他javascript都被渲染了. 谢谢一堆! 解决方法
如果这是一个新的Rails应用程序调试模式默认是打开的.调试模式告诉Sprockets将每个文件的标签写入HTML源代码.这样做是为了方便源文件调试.
如果你想在开发模式中只有一个文件去你的development.rb并设置: config.assets.debug = false 这将为每个清单提供一个文件. 压缩默认情况下不进行开发,但是如果您也希望这样做,则设置: config.assets.compress = true 并且您将需要将压缩器选项从production.rb移动到application.rb,以便开发环境可访问它们. 我在开发模式下调试,但我不使用压缩,因为处理文件需要额外的时间. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |