如何全局使用scss文件?

我已经在论坛上阅读了一些主题,但是老实说,我没有发现关于我的问题的任何具体信息。

I have several .scss files in my /assets/scss folder.

And these files are of different types, for example: placeholders and mixins.

Currently I give @import on these specific files, on the specific components which will use these files.

And this is getting a little weird, because I'm giving @import on several component .scss.

Is there any way I can use these without having to give @import on each .scss?

enter image description here

我的项目当前所在的示例:

@import '../../../assets/scss/mixins/breakpoints';

aside {
    @include breakpoint-desktop {
        width: 400px;
    }
}
评论
  • 时钟滴答响
    时钟滴答响 回复

    您可以将所有scss导入由angular cli(styles.scss)生成的主样式文件中,但是由于任何原因,您需要在特定组件中导入sass代码,因此可以在angular.json文件中配置路径以使用sass进行干净导入。

    "stylePreprocessorOptions": {
       "includePaths": [
       "src/assets"
     ]
    }
    

    现在,您可以像这样使用导入:

     @import 'placeholders/placeholder-1';
    

    You can find more information here