Rails 3.2&资产管道:开发模式下的JavaScript压缩

时间:2012-07-13 02:06:07

标签: ruby-on-rails compression asset-pipeline

是否可以在Rails 3.2中以开发模式提供压缩js? Gemfile包含

      gem "closure-compiler"

和development.rb包含

  config.serve_static_assets = true
  config.assets.compile = false
  config.assets.debug = false
  config.assets.js_compressor = :closure
  config.assets.compress = true

已经跑了

RAILS_ENV=development bundle exec rake assets:precompile

而且,即使已编译的application.js存在于:

./public/assets/application/application.js
./public/assets/application/application.js.gz
./public/assets/jasmine_rails/application.js
./public/assets/jasmine_rails/application.js.gz

......它永远不会得到服务。

1 个答案:

答案 0 :(得分:0)

此配置使其有效:

  config.cache_classes = true
  config.whiny_nils = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_assets = true
  config.assets.compress = true
  config.assets.js_compressor = :closure
  config.assets.debug = false
  config.assets.compile = false
  config.assets.digest = true