没有一个解决方案提供了工作。有些很接近,将更新大多数元素的颜色使用,但不是所有元素。我已经尝试了所有这些(以及我可以在 StackOverflow 和其他网站上找到的所有其他替代方案,但这些解决方案只会影响专门引用颜色属性的元素,并且不会更新那些使用主题颜色函数来获取颜色的元素。
The expected solution (and recommended by others) is
/* import only the necessary Bootstrap files */
@import "../../node_modules/bootstrap/scss/functions";
@import "../../node_modules/bootstrap/scss/variables";
/* -------begin customization-------- */
$colors: (
"" + blue: #004C9E
);
/* 80 required to bring primary and secondary colors to AAA standards */
$theme-colors: (
primary: #004C9E
);
// /* -------end customization-------- */
/* finally, import Bootstrap to set the changes! */
@import "../../node_modules/bootstrap/scss/bootstrap";
But this leaves 15 occurences of #007bff (the normal blue/primary color) throughout the generated custom.css. Examples of it occur in the pagination section, e.g.
.page-item.active .page-link {
z-index: 1;
color: #fff;
background-color: #007bff;
border-color: #007bff;
}
By setting both the $colors and the $theme-colors custom properties after the import of the functions.scss, and placing the statement to import the variables.scss AFTER these changes appears to set the new colors throughout. I presume that by setting these variables specifically, the bootstrap variables cannot override them.
@import "../../node_modules/bootstrap/scss/functions";
/* -------begin customization-------- */
$colors: (
"" + blue: #004C9E
);
/* 80 required to bring primary color to AAA standards */
$theme-colors: (
primary: #004C9E
);
@import "../../node_modules/bootstrap/scss/variables";
/* put other customization in here */
// /* -------end customization-------- */
/* finally, import Bootstrap to set the changes! */
@import "../../node_modules/bootstrap/scss/bootstrap";
The may not seem right, but it does appear to work. I'm not a SASS expert, so maybe someone else could explain this better. I hope this helps anyone who may still be struggling to solve this issue.