另一个问题 "在开发中禁用Sprockets资产缓存" 解决了如何在Rails 3.2中禁用Sprockets缓存。在Rails 4上怎么做相同的事情?我正在开发一个深入资产管道的gem,不得不清除tmp/cache/*
并重启Rails令人疲倦。
另一个问题 "在开发中禁用Sprockets资产缓存" 解决了如何在Rails 3.2中禁用Sprockets缓存。在Rails 4上怎么做相同的事情?我正在开发一个深入资产管道的gem,不得不清除tmp/cache/*
并重启Rails令人疲倦。
cache_classes
为true,则app.assets
将被设置为app.assets.index
,此时不再检查文件系统。development.rb
配置中添加类似于以下内容的内容。# Sprockets configuration: prevent sprockets from caching assets in development
# when cache_classes is set to true
sprockets_env = nil
config.assets.configure do |env|
sprockets_env = env
# Sprockets environment configuration goes here
# env.js_compressor = :uglifier # or :closure, :yui
# env.css_compressor = :sass # or :yui
end
if config.cache_classes
config.after_initialize do
Rails.application.assets = sprockets_env
end
end
cache_classes
为true时检查新资产的文件系统。这在开发中对我们有效,希望它也能帮助其他人。