将scss变量导入Angular组件

时间:2020-05-30 06:55:52

标签: angular webpack sass

假设我具有以下Angular组件:

// src/app/app.component.html
<stars [customColor]="blue">

我有以下scss变量:

// src/_styles.scss
$color: blue;

如何使用scss变量而不是复制blue

为澄清起见,我想访问$colorapp.component.html中的app.component.ts

显然可以使用configure Webpack in a React app,但是我不确定在Angular中是否可行。

1 个答案:

答案 0 :(得分:2)

在您的app.component.scss(或star.component.scss)文件中,只需导入您的样式即可:

@import './../_style.scss'

然后您可以使用scss var