【发布时间】:2015-01-24 02:47:52
【问题描述】:
我在安装 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 文件中将编译标志设置为 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 文件编译的同时,我能做些什么来修复它?还是我必须选择我的毒药?
谢谢。
【问题讨论】:
标签: ruby-on-rails asset-pipeline sprockets precompile