2016-05-12 80 views
1

我使用angular2-webpack-starter,我的樣式表爲SASS。一切都可以正常使用,但是當我嘗試運行業力測試中,它無法給我這個錯誤如何使一個webpack,Angular2和SASS項目的業力工作?

ERROR in ./src/app/widgets/message/messages.scss 
Module parse failed: d:\ui_widgets-A2\src\app\widgets\message\messages.scss Unexpected token (6:22) 
You may need an appropriate loader to handle this file type. 
SyntaxError: Unexpected token (6:22) 
    at Parser.pp.raise (d:\ui_widgets-A2\node_modules\acorn\dist\acorn.js:920:13) 
    at Parser.pp.unexpected (d:\ui_widgets-A2\node_modules\acorn\dist\acorn.js:1483:8) 
    at Parser.pp.semicolon (d:\ui_widgets-A2\node_modules\acorn\dist\acorn.js:1462:73) 
    at Parser.pp.parseExpressionStatement (d:\ui_widgets-A2\node_modules\acorn\dist\acorn.js:1976:8) 
    at Parser.pp.parseStatement (d:\ui_widgets-A2\node_modules\acorn\dist\acorn.js:1754:188) 
    at Parser.pp.parseTopLevel (d:\ui_widgets-A2\node_modules\acorn\dist\acorn.js:1648:21) 
    at Parser.parse (d:\ui_widgets-A2\node_modules\acorn\dist\acorn.js:1616:17) 
    at Object.parse (d:\ui_widgets-A2\node_modules\acorn\dist\acorn.js:882:44) 
    at Parser.parse (d:\ui_widgets-A2\node_modules\webpack\lib\Parser.js:902:15) 
    at DependenciesBlock.<anonymous> (d:\ui_widgets-A2\node_modules\webpack\lib\NormalModule.js:104:16) 
    at DependenciesBlock.onModuleBuild (d:\ui_widgets-A2\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10) 
    at nextLoader (d:\ui_widgets-A2\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25) 
    at d:\ui_widgets-A2\node_modules\webpack-core\lib\NormalModuleMixin.js:259:5 
    at Storage.finished (d:\ui_widgets-A2\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:38:16) 
    at d:\ui_widgets-A2\node_modules\graceful-fs\graceful-fs.js:78:16 
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:439:3) 
@ ./src/app/widgets/message/message.component.ts 9:431-457 

我試圖安裝karma-sass-preprocessorkarma-scss-preprocessor,但似乎沒有任何工作。我該怎麼辦?

回答

3

因此,答案是很瑣碎,我在webpack.common.js

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

由於某種原因,我認爲webpack.test.js也得到它,但事實證明,我應該也已經將它添加到webpack.test.js

相關問題