sass
。node-sass
,raw-loader
和sas-loader
并将该行添加到webpack.config.js中:
{ test: /\.scss$/, loaders: ["raw-loader", "sass-loader"] }
styleUrls: ['./home.component.scss']
home.component.scss
文件仅包含以下内容:
.body {
background-color: red
}
在空的visual studio模板中,'。body'与home组件中的任何元素都不匹配。
测试,尝试'home.component.scss':
$primary-color: red;
h1 {
color: $primary-color;
}
没有相应的css文件,已编译的css被写入html中的样式标记:
<style>
h1[_ngcontent-c2] {
color: red; }
</style>