search

Home  >  Q&A  >  body text

angular.js - Problem extracting sass files under ng2?

1. Components:

import { Component } from '@angular/core';

@Component({
    selector: 'app',
    template: require('./app.component.html'),
    styles: [ require('./app.component.scss') ]
})
export default class AppComponent{

}

2. Configuration in webpack:

...
{
    test: /\.scss$/,
    loader: ExtractTextPlugin.extract( 'style-loader', 'raw-loader!css-loader!sass-loader' ),
    exclude: /node_modules/
}
...

3. Report in the browser Uncaught Error: Expected 'styles' to be an array of strings.

4. How to extract scss files?

天蓬老师天蓬老师2841 days ago618

reply all(1)I'll reply

  • 漂亮男人

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

    Please use styleUrls, raw-loader should be executed last. However, if you need to AOT compile after using require, you will be in trouble.

    reply
    0
  • Cancelreply