【发布时间】:2021-05-11 19:08:15
【问题描述】:
我正在开发一个包含 bootstrap-sass 的 Rails 引擎。我正在尝试在我的样式中使用引导变量,但出现错误。我正在尝试遵循此处的文档:
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'
# ...
application.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 不应该由引导程序定义吗?我错过了什么?
【问题讨论】:
标签: ruby-on-rails sass rails-engines bootstrap-sass