Rails 3.1 Sprockets需要指令 - 有没有办法排除特定文件? [英] Rails 3.1 Sprockets require directives - is there a way to exclude particular files?

查看:76
本文介绍了Rails 3.1 Sprockets需要指令 - 有没有办法排除特定文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在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的新存根指令在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屋!

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