我在 production.rb 中有以下配置
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false
# Compress JavaScripts and CSS
config.assets.compress = true
# Choose the compressors to use
config.assets.js_compressor = :uglifier
config.assets.css_compressor = :yui
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true
# Generate digests for assets URLs.
config.assets.digest = true
但是当生产服务器上的 ruby on rails 应用程序时,我收到以下错误:
Error compiling CSS asset
LoadError: cannot load such file -- yui-compressor
在评论行
LoadError: cannot load such file -- yui-compressor
,一切顺利。我只需要一个压缩器,在发送之前 gzip 压缩 Assets 以提高性能!那么,这里有什么问题或者还有其他选择吗?
更新:javascript 压缩也不起作用,因为 yslow Firefox 插件也显示 javascripts 需要压缩。
最佳答案
您是否包含了 yui-compressor gem 在你的 Gemfile 中?如果没有,则包含它,运行“bundle install”,然后 Rails 应该能够找到它。
关于ruby-on-rails - 在 Ruby on Rails 3 中压缩 Assets ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14054158/