Angular 6 Library using bootstrap

后端 未结 6 2075
遇见更好的自我
遇见更好的自我 2021-02-19 13:14

I am creating an angular library in an angular project using angular 6 library feature https://github.com/angular/angular-cli/wiki/stories-create-library

I am creating f

6条回答
  •  有刺的猬
    2021-02-19 13:30

    I don't know if it answers your question, but firstly you have to add bootstrap to your library peer dependencies, after that, in all your projects which use that library you have to include bootstrap styles to global styles in angular.json.


    After that you can use bootstrap classes from templates in your library and you can be sure that styles would be applied. Also, if you want to use mixins or variables from bootstrap, you can just import needed scss bootstrap files into your components' scss files in library, like that:

    @import "~bootstrap/scss/bootstrap-grid";
    
    @include media-breakpoint-up(sm) {
        .some-class {
          display: block;
        }
    }
    

    During build all these imported scss files would be compiled and built into your library output files.


    There are other ways to include styles to library, but all of them require interception/extension of library build process.

提交回复
热议问题