1、组件:
import { Component } from '@angular/core';
@Component({
selector: 'app',
template: require('./app.component.html'),
styles: [ require('./app.component.scss') ]
})
export default class AppComponent{
}
2、在webpack中的配置:
...
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract( 'style-loader', 'raw-loader!css-loader!sass-loader' ),
exclude: /node_modules/
}
...
3、在浏览器下报Uncaught Error: Expected 'styles' to be an array of strings.
4、到底要怎么提取scss文件呢?
请用styleUrls,raw-loader应该放在最后执行。不过用了require以后要AOT编译的话你会踩坑的。