Rails 3.1 Pipeline - Exclude Javascript File

前端 未结 4 1174
醉话见心
醉话见心 2020-12-05 06:48

I want to exclude a particular javascript file (modernizr) from the pipeline because I want it to load separately.

I want to load Modernizr at the beginning and th

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 07:32

    I realize this is an old question, but Google sent me here last week so it's not an obsolete question. The answer I found elsewhere was the "stub" directive for sprockets. So something like

    //= require-tree .
    //= stub Modernizr
    

    This keeps Modernizr.js out of the bundled assets. It can be included with its own tag, à la the original answer.

    The Sprockets changelog says "stub" was added in January 2012, so it wouldn't have been available at the time this question was first answered, but I think it's a good answer now.

提交回复
热议问题