Rails 3.1 Sprockets需要指令 - 有没有办法排除特定文件? [英] Rails 3.1 Sprockets require directives - is there a way to exclude particular files?
问题描述
如果我在application.css中使用 // = require_tree。
,有没有办法排除特定文件而不是诉诸 / / = require_directory
和树组织?
If I'm using //=require_tree .
in application.css, is there a way to exclude particular files other than resorting to //=require_directory
and tree organization?
或许像 // = require_tree。,{except:'something' }
推荐答案
这可以通过Sprocket的新存根$ c来实现$ c>指令在Sprockets v2.2.0及更高版本中可用。但是,Rails 3.2只会使用没有此功能的Sprockets v2.1.3。截至目前,当前的Edge Rails具有
stub
指令,它将正式在Rails 4.0及更高版本中。
This is possible with Sprocket's new stub
directive which is available in Sprockets v2.2.0 and up. However, Rails 3.2 will only ever use Sprockets v2.1.3 which does not have this feature. As of now, the current Edge Rails has the stub
directive and it will officially be in Rails 4.0 and above.
用法:
//= require jquery
//= require_tree .
//= stub unwanted_js
stub
指令不能被后续的 require
或 include
指令覆盖。
stub
directives can not be overridden by subsequent require
or include
directives.
如果你想在你的Rails 3.2项目中使用 stub
指令,你将不得不切换到Edge Rails,或者修改其Sprockets依赖项的Rails gem。到2.2.0版。
If you want to use the stub
directive in your Rails 3.2 project you will have to switch to Edge Rails, or branch your Rails gem with its Sprockets dependency modified to version 2.2.0.
这篇关于Rails 3.1 Sprockets需要指令 - 有没有办法排除特定文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!