资产管道没有将javascripts压缩为application.js

jdk*_*aly 13 ruby-on-rails-3.1 asset-pipeline

我有两个问题.

  1. 我是否错误地假设我的所有javascripts都应该在rails 3.1中被压缩成application.js,即使在开发模式下也是如此?

  2. 如果没有,那么为什么我的标签包含我的所有30个javascripts并且需要加载?

我的application.js文件如下所示:

//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require_tree .
Run Code Online (Sandbox Code Playgroud)

在浏览器中,它呈现为:

// 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. 
//
;
Run Code Online (Sandbox Code Playgroud)

虽然我的所有其他javascripts都完整呈现.

谢天谢地!

Ric*_*lse 11

如果这是一个新的Rails应用程序默认情况下启用调试模式.调试模式告诉Sprockets将每个文件的标记写入HTML源代码.这样做是为了便于源文件调试.

如果您想在开发模式下只有一个文件,请转到您的development.rb并设置:

config.assets.debug = false

这将为每个清单提供一个文件.

默认情况下,压缩不会用于开发,但如果您也想要压缩,则设置:

config.assets.compress = true

您需要将压缩器选项从production.rb移动到application.rb,以便开发环境可以访问它们.

我在开发模式下关闭调试,但由于处理文件需要额外的时间,因此我不使用压缩.