Rails 3.1 管道 - 排除 Javascript 文件 [英] Rails 3.1 Pipeline - Exclude Javascript File
问题描述
我想从管道中排除特定的 javascript 文件 (modernizr),因为我希望它单独加载.
I want to exclude a particular javascript file (modernizr) from the pipeline because I want it to load separately.
我想在开头加载 Modernizr,并在最后连接我的 javascript 的其余部分.
I want to load Modernizr at the beginning and the rest of my javascript concatenated at the end.
有没有办法在 3.1 中的资产管道中执行与需求相反的操作?IE.排除?
Is there way to do the opposite of a require in the asset pipeline in 3.1? ie. an exclude?
提前致谢.
亚当.
推荐答案
我选择通过更改来保留链轮功能
I chose to keep the sprockets functionality by changing
//= require_tree
到
//= require_directory .
这使链轮自动加载同一目录中的任何文件,但不会进一步加载任何文件夹.
This keeps sprockets auto-loading any files in the same directory, but not in any folders further.
这让我可以将 Modernizr.js 移动到 assets/javascripts/top 文件夹并在顶部手动加载它:
This allowed me to move Modernizr.js to the assets/javascripts/top folder and manually load it at the top with:
<%= javascript_include_tag "top/modernizr" %>
并移动
<%= javascript_include_tag "application" %>
到我的 application.html.erb 文件的底部(在结束正文标记上方)
To the bottom of my application.html.erb file (above the closing body tag)
这篇关于Rails 3.1 管道 - 排除 Javascript 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!