无法设置"编译"使用自定义预编译时,标志为true

时间:2014-11-25 22:22:54

标签: ruby-on-rails asset-pipeline sprockets precompile

安装angulartics模块后,我遇到了此处描述的问题:

https://github.com/sstephenson/sprockets/issues/347#issuecomment-25543201

我使用了建议的解决方案来更改预编译的文件,以便不包含LICENSE文件:

# We don't want the default of everything that isn't js or css, because it pulls too many things in
config.assets.precompile.shift

# Explicitly register the extensions we are interested in compiling
config.assets.precompile.push(Proc.new do |path|
  File.extname(path).in? %w(.html .erb .haml .png .gif .jpg .jpeg .eot .otf .svc .woff .ttf)
end)

它有效......有点儿。问题是我需要在production.rb文件中将compile标志设置为true,这会大大减慢网站速度,尤其是第一次加载时:

config.assets.compile = true

如果我尝试坚持生产的默认值'false',每次尝试提供任何css或js代码时都会出错:

Nov 25 14:18:18 <...> app/web.1:  ActionController::RoutingError (No route matches [GET] "/stylesheets/sessions.css"): 
Nov 25 14:18:18 <...> app/web.1:    vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
...

为什么会这样?在避免LICENSE文件编译的同时,我还能做些什么来修复它吗?或者我必须选择我的毒药?

感谢。

1 个答案:

答案 0 :(得分:0)

当应该在application.rb中时,我将更改应用于application.rb中的config.assets.precompile。呸。简单的修复。

相关问题