Asset Pipeline: excluding an admin.css file

后端 未结 4 1652
北海茫月
北海茫月 2021-02-05 03:55

I upgraded a Rails 3.0 app to Rails 3.1 which involved putting this

/*
*= require_self
*= require_tree .
*/

in the application.css file. Howeve

4条回答
  •  Happy的楠姐
    2021-02-05 04:22

    Similar question was asked earlier and you should check that one.

    Sprockets uses manifest files to determine which assets to include and serve. These manifest files contain directives — instructions that tell Sprockets which files to require in order to build a single CSS or JavaScript file. With these directives, Sprockets loads the files specified, processes them if necessary, concatenates them into one single file and then compresses them (if Rails.application.config.assets.compress is true). By serving one file rather than many, the load time of pages can be greatly reduced because the browser makes fewer requests.

    You can have as many manifest files as you need. For example the admin.css and admin.js manifest could contain the JS and CSS files that are used for the admin section of the application.

    In particular, you can specify individual files and they are compiled in the order specified.

    Example and more details can be found in this guide.

    Thus, your new application.css would become:

    /*
     *= require styles
     *= require layout
     */
    
    /* Other styles */
    

提交回复
热议问题