问题描述
我一直在将应用程序过渡到Rails 3.1(现在过渡到3.2),并观看了资产管道上的广播.我将所有第三方jquery插件文件都移到了/vendor/assets/javascripts/目录.在我的/app/assets/javascripts/application.js中,我有以下内容:
I've been transitioning an app to Rails 3.1 (and now on to 3.2) and watched the Railscast on the asset pipeline. I moved all of my third-party jquery plugin files to the /vendor/assets/javascripts/ directory. In my /app/assets/javascripts/application.js I have the following:
//= require jquery
//= require jquery_ujs
//= require_tree .
//= require_self
我意识到require_tree .
调用只会加载/app/assets/javascripts/目录的树. (正确吗?)包括 all 所有供应商" javascript的最佳方法是什么? (我现在不担心订购.)当然,我可以在/app/assets/javascripts/application.js中逐行要求它们.我的另一个想法是使用以下代码创建/vendor/assets/javascripts/vendor_javascripts.js:
I realized the require_tree .
call only loads the tree for the /app/assets/javascripts/ directory. (Is that correct?) What's the best way to include all the "vendor" javascripts? (I'm not worried about ordering at this point.) Of course I could require them line by line in /app/assets/javascripts/application.js. My other thought was to create /vendor/assets/javascripts/vendor_javascripts.js with the following:
//= require_tree .
然后在/app/assets/javascripts/application.js中添加以下内容:
And then in /app/assets/javascripts/application.js add the following:
//= require vendor_javascripts
这似乎有些笨拙.有没有更好的方法来自动包含所有供应商"(和/或"lib")javascripts?
This seems a little clunky though. Is there a better way to automatically include all the "vendor" (and/or "lib") javascripts?
PS.我看到了关于index.js文件的信息,但我最终可能会失败有多个名为index.js的文件,对吗?哦,我尝试重新启动服务器.
PS. I saw this about index.js files, but I would potentially end up with multiple files named index.js, right? Oh, and I tried restarting my server throughout.
推荐答案
您可以在app/assets/javascripts/application.js
文件中添加如下所示的内容,以包含所有供应商的javascript:
You can add something like this in your app/assets/javascripts/application.js
file to include all the vendor javascripts:
//= require_tree ../../../vendor/assets/javascripts/.
这篇关于Rails资产管道:包括所有/vendor/assets/javascripts/?的标准方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!