目前,我的事件 CSS 位于 app/assets/stylesheets/pages/events.scss
中,在开发模式下它看起来不错, Assets 已加载。但是在生产环境中,这些页面似乎根本没有加载。我不确定如何解决这个问题。我看过 Rails 4: assets not loading in production但我不熟悉 config.assets.precompile += %w( *.js ^[^_]*.css *.css.erb)
因为路径本身似乎不是在生产中工作。
应用程序/ Assets /样式表/application.scss:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
*#= require bootstrap-wysihtml5
*#= require rails_bootstrap_forms
*#= require jquery.jcrop
*= require custom
*= require_self
*/
@import "bootstrap-sprockets";
@import "bootstrap";
@import "scaffolds";
应用程序/views/events/index.html.erb:
<% content_for :head do %>
<%= stylesheet_link_tag "pages/events", :media => "all" %>
<% end %>
app/assets/stylesheets/pages/events.scss
@import "globals/helpers";
@import "vendors/animate";
.events-bar {
/* a[class*="btn"] {
height: 36px;
display: inline-block;
}*/
#toggleBar {
margin-top: 14px;
}
.btn-dashboard {
background-color: #fdf9ff;
color: $eventsColour !important;
&:hover {
background-color: $eventsColour-dark !important;
}
}
}
它很难调试,因为它在开发中运行良好,但在生产中运行不佳。看起来子目录 (app/assets/stylesheet/pages/*.scss) 中的所有文件在生产环境中都不起作用。任何见解都会有所帮助,谢谢。
最佳答案
你只需要将事件添加到你的预编译 Assets 列表中,因为它不是用 application.scss
编译的,你想要的格式是
config.assets.precompile += %w( pages/events.scss )
然后
bundle exec rake assets:precompile
关于css - Rails Assets 位于子目录中,无法在生产环境中加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38196678/