Rails 3.1 Pipeline - Exclude Javascript File

前端 未结 4 1182
醉话见心
醉话见心 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:24

    I chose to keep the sprockets functionality by changing

    //= require_tree
    

    to

    //= require_directory .
    

    This keeps sprockets auto-loading any files in the same directory, but not in any folders further.

    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" %>
    

    and move

    <%= javascript_include_tag "application" %>
    

    To the bottom of my application.html.erb file (above the closing body tag)

提交回复
热议问题