我有我的主应用程序css,我想要排除我的后端样式表,因为当application.css执行*=require_tree .
我目前的文件夹设置如下:
assets/
stylesheets/
main/ #application.css ##other css files for front end
backend/ #backend.css ##other css files for back end
我的application.css如下:
/*
*= require_self
*= require foundation_and_overrides
*= require_tree ./main/
*/
backend.css
/*
*= require_self
*= require foundation_and_overrides
*= require_tree ./backend/
*/
在我的application.rb
中config.assets.precompile += ['application.css', 'backend.css']
my development.rb
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
我尝试移动样式表并使用不同的目录,但我要么根本没有加载样式表,要么会收到“找不到foundation_and_overrides”......
有一种简单干净的方法吗? 我只想排除使用application.css编译的几个样式表
答案 0 :(得分:1)
链轮的全部意义在于您包含所需的内容。您始终可以将另一个样式表添加到页面中。最好与用户编译成一个,但如果管理员使用后端,添加另一个样式表就完全没问题了。
首先,application.css
已预先编译,因此您只需要:
config.assets.precompile << 'backend.css'
可选择添加一个样式表,因此application.css
有基础等,backend.css
只有其他样式:
<%= stylesheet_link_tag 'application', media: :all %>
<% if admin? %>
<%= stylesheet_link_tag 'backend', media: :all %>
<% end %>
如果由于某种原因shared
样式与application.css
样式冲突,您还可以为两者都添加样式表backend.css
目录。
+ stylesheets
+ shared
+ app
+ backend
- application.css
- backend.css
两者中require_tree ./shared
。