如何在Angular2种子项目中实施SCSS?

时间:2017-02-27 14:31:14

标签: css angular typescript sass

如何在Angular2种子项目中实施SCSS。是否有更好的教程或参考网站可以看到这个?

我尝试在此链接中实现相同的功能 https://github.com/AngularClass/angular2-webpack-starter/wiki/How-to-include-SCSS-in-components

但我收到此错误

ERROR in ./src/app/components/subscription/subscription.component.scss
Module parse failed: C:\indiaAbroad\iaApp\src\app\components\subscription\subscription.component.scss Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
| .subscription {
|
| }
 @ ./src/app/components/subscription/subscription.component.ts 18:21-61
 @ ./src/app/config/app.module.ts
 @ ./src/main.browser.ts
 @ multi main                                            Hash: e76bd7a5a02aa33e1272  

3 个答案:

答案 0 :(得分:2)

  

npm install node-sass sass-loader raw-loader --save-dev

     

在webpack.common.js中,搜索“rules:”

{
    test: /\.scss$/,
    exclude: /node_modules/,
    loaders: ['raw-loader', 'sass-loader'] // sass-loader not scss-loader
}
     

source

答案 1 :(得分:2)

你所做的是正确的。

安装后,此软件包重新启动npm服务器。它会工作!!!

答案 2 :(得分:1)

您可以使用Angular ClI。它支持sass样式

https://github.com/angular/angular-cli

ng new project --style scss