suchen

Heim  >  Fragen und Antworten  >  Hauptteil

angular.js - ng2下提取sass文件有问题?

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文件呢?

天蓬老师天蓬老师2841 Tage vor613

Antworte allen(1)Ich werde antworten

  • 漂亮男人

    漂亮男人2017-05-15 17:11:52

    请用styleUrls,raw-loader应该放在最后执行。不过用了require以后要AOT编译的话你会踩坑的。

    Antwort
    0
  • StornierenAntwort