gpt4 book ai didi

sass - Bootstrap 和 Angular 8. _root.scss 中 undefined variable

转载 作者:行者123 更新时间:2023-12-02 22:03:09 28 4
gpt4 key购买 nike

我今天尝试将项目更新到 Angular 8.0.0,但遇到了 bootstrap 问题,无法找到解决方案。

我使用bootstrap 4.3.1

当我执行ngserve时,我收到此错误:

ERROR in ./node_modules/bootstrap/scss/bootstrap.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--13-3!./node_modules/bootstrap/scss/bootstrap.scss)
Module build failed (from ./node_modules/sass-loader/lib/loader.js):

@each $color, $value in $colors {
^
Undefined variable.

3 │ @each $color, $value in $colors {
│ ^^^^^^^

node_modules/bootstrap/scss/_root.scss 3:27 @import
stdin 11:9 root stylesheet
in ./node_modules/bootstrap/scss/_root.scss (line 3, column 27)

在我的 angular.json 中,我有这个(我刚刚包含了与 scss 相关的部分):

  "schematics": {
"@schematics/angular:component": {
"style": "sass"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets",
"src/manifest.json"
],
"styles": [
"./node_modules/bootstrap/scss/bootstrap.scss",
"./node_modules/c3/c3.css",
"./node_modules/@fortawesome/fontawesome-free/css/all.css",
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"./src/styles/styles.scss"
],
"stylePreprocessorOptions": {
"includePaths": [
"src/styles"
]
},
"scripts": [],
"es5BrowserSupport": true
},

根据我对错误的理解,这是由于全局 scss 变量不可用,在 "./node_modules/bootstrap/scss/bootstrap.scss" 中,它看起来像这个:

@import "functions";
@import "variables";
@import "mixins";
@import "root";
@import "many_other_stuff"

$colors 变量在 "variables" 中定义,因此它应该在 "root" 中可用。

知道我在这里做错了什么吗?

最佳答案

应该是 scss 而不是 sass :

"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},

谢谢

关于sass - Bootstrap 和 Angular 8. _root.scss 中 undefined variable ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56378554/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com