Rails 3.1资产预编译-包括所有JavaScript文件 [英] Rails 3.1 asset precompilation - include all javascript files
问题描述
我希望Rails 3.1可以提取更多资源进行预编译.特别是,用于编译文件的默认匹配器不会从vendor/assets/javascripts
添加.js
文件.我可以将资产添加到config.assets.precompile
列表中,但这似乎很烦人.我不想在application.js
清单中引用它们,因为我不希望它们包含在所有页面中.
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.
总而言之,有什么方法可以要求在vendor/assets/javascripts
中找到的所有.js
文件都由rake assets:precompile
预编译,但是没有将它们包含在所有页面中?
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?
推荐答案
config.assets.precompile
接受正则表达式和通配符匹配-因此,确保所有 js文件被编译,而无需按名称指定每个像这样应该可以解决问题:
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'
这篇关于Rails 3.1资产预编译-包括所有JavaScript文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!