相关疑难解决方法(0)

Rails中适当的SCSS资产结构

所以,我有一个app/assets/stylesheets/看起来像这样的目录结构:

   |-dialogs
   |-mixins
   |---buttons
   |---gradients
   |---vendor_support
   |---widgets
   |-pages
   |-structure
   |-ui_elements
Run Code Online (Sandbox Code Playgroud)

在每个目录中,有多个sass partials(通常是*.css.scss,但是一个或两个*.css.scss.erb).

我可能会假设很多,但rails应该自动编译那些目录中的所有文件,因为*= require_tree .在application.css中,对吧?

我最近尝试通过删除所有颜色变量并将它们放在根app/assets/stylesheets文件夹(_colors.css.scss)中的文件中来重构这些文件.然后我在app/assets/stylesheets名为master.css.scss 的根文件夹中创建了一个文件,如下所示:

// Color Palette 
@import "colors";

// Mixins
@import "mixins/buttons/standard_button";
@import "mixins/gradients/table_header_fade";
@import "mixins/vendor_support/rounded_corners";
@import "mixins/vendor_support/rounded_corners_top";
@import "mixins/vendor_support/box_shadow";
@import "mixins/vendor_support/opacity";
Run Code Online (Sandbox Code Playgroud)

我真的不明白rails如何处理资产编译的顺序,但它显然不利于我.看来没有一个文件意识到他们有任何变量或mixins被导入,所以它抛出错误,我无法编译.

Undefined variable: "$dialog_divider_color".
  (in /home/blah/app/assets/stylesheets/dialogs/dialog.css.scss.erb)

Undefined mixin 'rounded_corners'.
  (in /home/blah/app/assets/stylesheets/widgets.css.scss)
Run Code Online (Sandbox Code Playgroud)

该变量$dialog_divider_color在_colors.css.scss中明确定义,并_master.css.scss导入颜色和我的所有mixins.但显然铁路没有获得那份备忘录.

有什么方法可以解决这些错误,还是我需要将所有变量定义放回每个单独的文件,以及所有mixin导入?

不幸的是,这家伙似乎并不认为这是可能的,但我希望他错了.任何想法都非常感谢.

css ruby-on-rails sass asset-pipeline

82
推荐指数
3
解决办法
5万
查看次数

bootstrap-sass:未定义的变量:"$ baseLineHeight"

我使用bootstrap-sass将bootstrap集成到我的应用程序中.该应用程序在我的本地计算机上工作正常,但当我通过capistrano部署时,我收到此错误:

Undefined variable: "$baseLineHeight".
(in /var/www/CollegeSportsBlueBook/shared/bundle/ruby/1.9.1/gems/bootstrap-sass-2.0.1/vendor/assets/stylesheets/bootstrap/_accordion.scss)
Run Code Online (Sandbox Code Playgroud)

当capistrano试图跑 assets:precompile

我认为这个变量抛出错误,因为它是第一个尝试预编译的scss文件中的第一个变量.

有些事情没有正确加载.任何想法可能是什么?

编辑

完整跟踪https://gist.github.com/2233071

编辑2

将application.rb和production.rb添加到gist

ruby-on-rails twitter-bootstrap bootstrap-sass

17
推荐指数
1
解决办法
1万
查看次数

使用带有rails资产管道的twitter bootstrap更少

如何正确整合twitter-bootstrap-rails gem和资产管道?

我已经按照安装步骤进行操作,目前我有这个application.css

 *= require_self
 *= require bootstrap_and_overrides
Run Code Online (Sandbox Code Playgroud)

然后在bootstrap_and_overrides.css.less中我导入其他控制器样式表,以使它们与我在覆盖文件中定义的变量一起使用,并且能够在<controller-name>.css.less文件中的控制器特定样式表中使用bootstrap mixins .目前我这样做:

# 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; …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails less sprockets asset-pipeline twitter-bootstrap

4
推荐指数
1
解决办法
3882
查看次数