How to use Bootstrap 4 with SASS in Angular

前端 未结 5 557
野的像风
野的像风 2020-12-12 12:50

I\'d like to use Bootstrap 4 with SASS in an Angular(4+) project created with Angular CLI.

In particular I need to:

  • use SASS instead of CSS both as glo
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-12 13:01

    In addition to @ShinDarth's answer, you may want to go for a more minimal solution, importing only the Bootstrap modules you need instead of them all.

    So you would replace:

    "styles": [
      "../node_modules/bootstrap/scss/bootstrap.scss",
      "assets/scss/main.scss"
    ],
    

    With:

    "styles": [
      "assets/scss/main.scss"
    ],
    

    Then your main.scss would look like:

    // import only the Bootstrap modules you need, e.g.
    @import "~bootstrap/scss/functions";
    @import "~bootstrap/scss/variables";
    @import "~bootstrap/scss/mixins";
    @import "~bootstrap/scss/grid";
    @import "~bootstrap/scss/navbar";
    @import "~bootstrap/scss/forms";
    // import your own custom files, e.g.
    @import "variables";
    @import "global";
    

提交回复
热议问题