Cannot set "compile" flag to true when using custom precompilation

69 views Asked by At

I am running into the problem described here after installing the angulartics module:

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

I used the suggested solution of changing the files that are precompiled such that the LICENSE file would not be included:

# 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)

And it works... sort of. The problem is that I need to set the the compile flag to true in the production.rb file, which slows down the website considerably, especially when loading it for the first time:

config.assets.compile = true

If I try to stick to the default of 'false' for production, I get errors every time I try to serve up any css or js code:

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'
...

Why is this happening? Is there anything I can do to fix it while still avoiding the LICENSE file compilation? Or do I have to pick my poison?

Thanks.

1

There are 1 answers

0
RocketGuy3 On BEST ANSWER

Turns out I put the change to config.assets.precompile in application.rb when it should be in production.rb. Bah. Simple enough fix.