Rails 3.1 / Compass / sprockets - генерация css дважды

Используя версии github ветки compass rails31 и sass-rails:

gem "sass-rails", :git => "https://github.com/rails/sass-rails.git"
gem "compass", :git => "https://github.com/chriseppstein/compass.git", :branch => "rails31"

Я создал частичный (_base.css.scss), который содержит импорт для blueprint / reset и blueprint-typography. У меня также есть файл screen.css.scss, который включает мою базовую партицию.

Когда rails компилирует это в application.css, я дважды вижу мои сбросы и типографику css.

таблицы стилей / application.css.scss

/*
 * This is a manifest file that'll automatically include all the stylesheets available in this directory
 * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
 * the top of the compiled file, but it's generally better to create a new file per style scope.
 *= require_self
 *= require_tree .
*/

таблицы стилей / частичные / _base.css.scss

@import "blueprint/reset";
@import "blueprint/typography";

@include blueprint-typography;

таблицы стилей / партиалы / screen.css.scss

@import "partials/_base";

#container { @include container; }

Я действительно не понимаю, что здесь происходит, и какова правильная конфигурация, чтобы начать использовать компас с рельсами 3.1

Большое спасибо за ваш совет!


person benoitr    schedule 21.06.2011    source источник


Ответы (3)


Если вы используете

require_tree .

в вашем манифесте application.css он автоматически включит все файлы в каталоге, содержащем этот файл.

Попробуйте использовать следующий метод в манифесте application.css вместо использования @import:

/*
  *= require blueprint/src/reset
  *= require blueprint/src/typography 
  *= require_self
  *= require_tree . 
*/

Кроме того, вы можете разместить план в vendor / assets / stylesheets вместо app / vendor (который должен содержать конкретный код приложения).

person Johny    schedule 01.08.2011

Вот мое решение, возможно, это не так. Это должно быть сделано (я действительно не знаю, как использовать звездочки), но, похоже, оно работает ... Пожалуйста, дайте мне знать, есть ли лучший способ добиться этого.

application.css.scss

/*
 * This is a manifest file that'll automatically include all the stylesheets available in this directory
 * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
 * the top of the compiled file, but it's generally better to create a new file per style scope.
 *= require_self
 *= require_tree .
*/

@import "blueprint/reset";
@import "blueprint/typography";

@include blueprint-typography;

screen.css.scss

@import "blueprint";
@import "partials/_base";

#container { @include container; }

_base.css.scss

# Columns or colors variables goes here...
person benoitr    schedule 23.06.2011
comment
Спасибо за ответ на свой вопрос. Я тоже застрял. - person danneu; 07.07.2011

Возможно, это не ваш случай, но одна из причин, по которой css загружается дважды, заключается в том, что вы добавляете расширение файла (например, .css) в свой оператор @import.

person konyak    schedule 15.05.2015