Rails 3.1 Pipeline-排除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?
谢谢.
亚当.
推荐答案
我选择通过更改
//= require_tree
到
//= require_directory .
这可使链轮自动加载同一目录中的任何文件,但不会进一步加载任何文件夹中的文件.
This keeps sprockets auto-loading any files in the same directory, but not in any folders further.
这使我可以将Modernizr.js移至asset/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文件底部(在body标记上方)
To the bottom of my application.html.erb file (above the closing body tag)
这篇关于Rails 3.1 Pipeline-排除Javascript文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!