Ошибка в rake app:assets:precompile при использовании переменной bootstrap sass в движке rails

Я работаю над движком rails, который включает в себя bootstrap-sass. Я пытаюсь использовать переменную начальной загрузки в своих стилях, но получаю сообщение об ошибке. Я пытаюсь следовать документации здесь:
https://www.rubydoc.info/gems/bootstrap-sass/3.4.1

# test_engine.gemspec

# ...

  s.add_dependency "rails", ">= 5"
  s.add_dependency 'sassc-rails'
  s.add_dependency 'bootstrap-sass'
# ...

приложение.scss:

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any styles
 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
 * file per style scope.
 *
 */

@import "bootstrap-sprockets";
@import "bootstrap";
@import "bootstrap-variables";

Я определил файл манифеста для фиктивного приложения, в котором выполняется задача rake:
test/dummy/app/assets/config/manifest.js

//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
//= link test_engine_manifest.js

И файл манифеста для моего движка:
app/assets/config/test_engine_manifest.js

//= link_directory ../javascripts/test_engine .js
//= link_directory ../stylesheets/test_engine .css

Вот файл, в котором я пытаюсь использовать переменную:

// _thing.scss

.thing {
  color: $brand-primary;
}

и вывод rake app:assets:precompile

> ❯❯❯ rake app:assets:precompile                                                                                                            

rake aborted!
SassC::SyntaxError: Error: Undefined variable: "$brand-primary".
        on line 2:10 of app/assets/stylesheets/test_engine/_thing.scss
>>   color: $brand-primary;

   ---------^

Разве $brand-primary не должен определяться бутстрапом? Что мне не хватает?


person Fred Willmore    schedule 11.05.2021    source источник


Ответы (1)


в вашем файле application.scss добавьте эту строку

@import "bootstrap-variables";

надеюсь, это сработает для вас. Спасибо.

person smehsan    schedule 11.05.2021
comment
Спасибо за предложение, но оно не решило мою проблему. Однако я заметил кое-что: если я включаю оператор @import, который ссылается на что-то, что, как я знаю, не существует, например, @import "xyz-variables";, я получаю ту же ошибку (в отличие от ошибки, говорящей, что он не может найти импорт). Так что, возможно, я пропустил шаг, чтобы включить application.scss - person Fred Willmore; 11.05.2021