如何正确整合twitter-bootstrap-rails Assets 管道的 gem ?
我已经按照安装步骤进行操作,目前我有这个 application.css
*= require_self
*= require bootstrap_and_overrides
然后在 bootstrap_and_overrides.css.less 中,我正在导入其他 Controller 样式表,以使它们与我在覆盖文件中定义的变量一起工作,并能够在
<controller-name>.css.less
中的 Controller 特定样式表中使用 Bootstrap 混合。文件。目前我正在这样做:# in bootstrap_and_overrides.css.less
// generated code ...
// Your custom LESS stylesheets goes here
//
// Since bootstrap was imported above you have access to its mixins which
// you may use and inherit here
//
// If you'd like to override bootstrap's own variables, you can do so here as well
// See http://twitter.github.com/bootstrap/less.html for their names and documentation
//
// Example:
// @linkColor: #ff0000;
@linkColor: #ff0000;
// import all other stylesheets
@import 'home.css.less';
@import 'users.css.less';
// and so on, once for every controller
// in home.css.less
#foobar {
.border-radius(30px); // bootstrap mixin
color: @linkColor; // inherited variable
}
但是,通过这种方式,我失去了 Assets 管道,并且在开发模式下我再也看不到单独的样式表了。有什么方法可以让 twitter-bootstrap-rails 与 sprockets 一起工作?
最佳答案
想想this github上的问题解释了您的问题。 (我知道这是为了sass,但无论如何解释应该是有效的)
简而言之,使用 sprocket 将单独编译每个文件,这意味着您不能使用 twitter Bootstrap 框架定义的变量和 mixin。所以我想答案是否定的:)
关于ruby-on-rails - 将 twitter bootstrap 与 rails assets pipeline 和 less 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10281907/