Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap SCSS error after angular update

I have recently upgraded my project from angular version 7 to 8. But when I issue command npm start I am seeing a lot of warnings like the following related with Bootstrap.

WARNING: You probably don't mean to use the color value gray in interpolation here.
It may end up represented as gray, which will likely produce invalid CSS.
Always quote color names when using them as strings or map keys (for example, "gray").
If you really want to use the color value here, use '"" + $color'.

   ╷
48 │   .alert-#{$color} {
   │            ^^^^^^
   ╵
    node_modules/bootstrap/scss/_alert.scss 48:12  @import
    src/scss/bootstrap.scss 46:9                   @import
    src/scss/theme/application.scss 18:9           @import
    stdin 1:9                                      root stylesheet

After this the compilation is failing with following error message

ERROR in ./src/scss/styles.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!./src/scss/styles.scss)
Module build failed (from ./node_modules/sass-loader/lib/loader.js):

    @extend .input-no-border:focus;
           ^
      Compound selectors may no longer be extended.
Consider `@extend .input-no-border, :focus` instead.
See https://sass-lang.com/documentation#extending_compound_selectors for details.

    ╷
209 │     @extend .input-no-border:focus;
    │             ^^^^^^^^^^^^^^^^^^^^^^
    ╵
  src/scss/theme/_utils.scss 209:13  root stylesheet
      in /src/scss/theme/_utils.scss (line 209, column 13)
like image 820
Happy Coder Avatar asked Jun 15 '19 04:06

Happy Coder


People also ask

Can I use SCSS instead of CSS in angular 13?

There might be chances you have set up your angular application with CSS styles but later you want to change it to use SCSS instead. This blog post will show how we can change the existing Angular 13 application to use SCSS instead of CSS.

Can I use bootstrap in angular?

Now, bootstrap has been added into your Angular app, and you can use some bootstrap built-in classes like float-left, float-right, text-left, text-right and etc. Adding preprocessor stylesheet language gives more flexibility to make your app vivid and makes managing your stylesheet variables in an easier way.

How to use bootstrap SCSS variables and mixins?

To use declared variables and mixins, just simply @import '../../styles/index.scss'; in your component’s scss file. 5. Utilize Bootstrap SCSS Variables

Why am I getting MDB error in Angular 8?

This error occurs only when you use MDB Angular in project with Angular v8 (because in this version more strict sass compiler is used). MDB is not ready yet to be used with Angular 8, we are currently working on it.


2 Answers

try this:-

npm rebuild node-sass
like image 173
Ronak Khangaonkar Avatar answered Sep 19 '22 08:09

Ronak Khangaonkar


it's not necessary to use node-sass. This problem is usually you have a problem with your sass variables like this :

$theme-color: (
  primary: #ababab,
  secondary: #gegege,
)

adding quote to the key will solve the problem

$theme-color: (
  'primary': #ababab,
  'secondary': #gegege,
)
like image 39
Huantao Avatar answered Sep 19 '22 08:09

Huantao