Rails 3.1 Sprockets require directives - is there a way to exclude particular files?

后端 未结 5 950
独厮守ぢ
独厮守ぢ 2020-12-28 12:24

If I\'m using //=require_tree . in application.css, is there a way to exclude particular files other than resorting to //=require_directory and tre

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-28 12:39

    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.

    Usage:

    //= require jquery
    //= require_tree .
    //= stub unwanted_js
    

    stub directives can not be overridden by subsequent require or include directives.

    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.

提交回复
热议问题