2

是否可以在 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

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

4

1 回答 1

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
于 2012-07-16T23:55:59.837 回答