简体   繁体   English

Angular 2中的全局.scss文件

[英]Global .scss file in Angular 2

Is it possible to use a global .scss file outside of individual components? 是否可以在单个组件之外使用全局.scss文件? I did an "ng set defaults.styleExt scss" for using .scss in components but I can't really create a global .scss file in src or app. 我为在组件中使用.scss做了一个“ ng set defaults.styleExt scss”,但是我真的不能在src或app中创建全局.scss文件。 I'm using the new webpack/cli Any ideas? 我正在使用新的webpack / cli有什么想法吗?

Just today README file for angular-cli was changed and included info about global style sheet. 就在今天,angular-cli的README文件已更改,并包含有关全局样式表的信息。 ( https://github.com/angular/angular-cli#global-styles ) https://github.com/angular/angular-cli#global-styles

Try adding styles.scss in either root folder or in app. 尝试在根文件夹或应用程序中添加styles.scss。

Your best option for now is to create a new scss file, and @import it in the beginning of your *.scss component. 目前最好的选择是创建一个新的scss文件,并在*.scss组件的开头@import It's not perfect at all, but that way you can create a single source for variables and mixins (for now). 它根本不是完美的,但是通过这种方式,您可以为变量和mixin创建单个源(目前)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM