sass-loader的CSS错误无效

时间:2015-11-02 22:27:27

标签: angularjs webpack webpack-style-loader sass-loader css-loader

我的app.scss

.tes {
    color: red;
}

执行./node_modules/.bin/webpack

时的输出错误
ERROR in ./~/css-loader!./~/sass-loader?indentedSyntax!./www/assets/app.scss
Module build failed: 
.tes {
     ^
      Invalid CSS after ".tes {": expected "}", was "{"
      in ./www/assets/app.scss (line 1, column 7)
 @ ./www/assets/app.scss 4:14-135 13:2-17:4 13:2-17:4 14:20-141

我的webpack.config

 module: {
        loaders: [
            {
                test: /\.scss$/,
                loader: 'style!css!sass?indentedSyntax'
            },
            {
                test: /\.css$/,
                loader: 'style!css'
            }, {
                test: /\.(woff|woff2|ttf|eot|svg)(\?]?.*)?$/,
                loader: 'file-loader?name=res/[name].[ext]?[hash]'
            }
        ]
    },

我的app.js

require('./www/assets/app.scss');

var angular = require('angular');
var uiRouter = require('angular-ui-router');
require('velocity-animate');
require('node-lumx');

var HomeController = require('./www/components/home/homeController');

angular.module('app', ['lumx', uiRouter]) 
... //OMITED

2 个答案:

答案 0 :(得分:2)

尝试使用sass loader而不使用“indentedSyntax”选项作为'style!css!sass'

更多信息,您可以在此处阅读文档:http://sass-lang.com/documentation/file.INDENTED_SYNTAX.html

答案 1 :(得分:1)

如果您想使用sass语法,解决方案是将文件扩展名更改为sass,因为从版本3.2.0开始,sass-loader将从文件扩展名派生您要使用的样式。 它对我有用。