Rails 3.1资产预编译-包括所有JavaScript文件 [英] Rails 3.1 asset precompilation - include all javascript files

查看:63
本文介绍了Rails 3.1资产预编译-包括所有JavaScript文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆