资产管道:排除admin.css文件 [英] Asset Pipeline: excluding an admin.css file
问题描述
我将一个Rails 3.0应用程序升级到了Rails 3.1,其中涉及到放置
I upgraded a Rails 3.0 app to Rails 3.1 which involved putting this
/*
*= require_self
*= require_tree .
*/
在application.css文件中.但是,有一个admin.css文件现在可以覆盖主应用程序css文件.
in the application.css file. However, there's an admin.css file that's now overriding the main app css file.
是否有一种方法可以将admin.css文件排除在外?在网站的管理"部分中,我手动添加了admin.css文件,但我需要一种从用户界面中将其排除的方法.
Is there a way to exclude the admin.css file from being included? In the admin section of the site I manually include the admin.css file but I need a way to exclude it from the user interface.
推荐答案
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.
您可以根据需要拥有任意数量的清单文件.例如,admin.css和admin.js清单可能包含用于应用程序admin部分的JS和CSS文件.
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.
因此,您的新application.css将变为:
Thus, your new application.css would become:
/*
*= require styles
*= require layout
*/
/* Other styles */
这篇关于资产管道:排除admin.css文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!