Rails 3.1 asset precompilation – include all javascript files

asset-pipelineruby-on-rails-3.1

I want Rails 3.1 to pick up more of my assets for precompilation. In particular, the default matcher for compiling files doesn't add .js files from vendor/assets/javascripts. I can just add the assets to the config.assets.precompile list, but this seems annoying. I don't want to refer to them in the application.js manifest, because I don't want them included in all pages.

In summary, any way to request that all .js files found in vendor/assets/javascripts get precompiled by rake assets:precompile, but without having them included in all pages?

Best Answer

config.assets.precompile accepts regular expressions and wildcard matching - so to ensure all js files get compiled, without specifying each by name, something like this should do the trick:

config.assets.precompile << '*.js'