Angular 6 library shared stylesheets

后端 未结 4 1263
清酒与你
清酒与你 2021-01-31 03:28

How can you setup a index.scss and import global stylesheets for variables, mixins, etc, to an angular 6 library?

Angular CLI generates a lib with a root component &

4条回答
  •  终归单人心
    2021-01-31 04:09

    Have you tried setting the encapsulation level of the component to none as part of the component metadata? Like this:

    @Component({
      selector: 'app-component',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.scss'],
      encapsulation: ViewEncapsulation.None
    })
    

    The ViewEncapsulation levels are:

    • ViewEncapsulation.Emulated: The default, Angular emulates a Shadow DOM.
    • ViewEncapsulation.Native: Use the browser's own Shadow DOM.
    • ViewEncapsulation.None: Styles are Global

    Check out the Angular Docs on ViewEncapsulation and I wrote a blog post on it.

提交回复
热议问题