2016-03-28 67 views
1

当试图青菜,加载程序添加到我的WebPack的配置和运行到一个错误抛出错误:的WebPack ExtractTextPlugin加载萨斯

70% 1/1 build modules/Users/a557789/Documents/f/Portal/node_modules/webpack/node_modules/webpack-core/lib/LoadersList.js:81 
     r.forEach(function(r) { 
     ^
TypeError: undefined is not a function 
    at /Users/a557789/Documents/f/Portal/node_modules/webpack/node_modules/webpack-core/lib/LoadersList.js:81:5 
    at Array.reduce (native) 
    at LoadersList.match (/Users/a557789/Documents/f/Portal/node_modules/webpack/node_modules/webpack-core/lib/LoadersList.js:80:27) 

webpack.config:

var webpack = require("webpack"); 
var baseDir = "dist"; 

var HtmlWebpackPlugin = require('html-webpack-plugin'); 
var ExtractTextPlugin = require("extract-text-webpack-plugin"); 

var path = require("path"); 

module.exports = { 
    context: __dirname + "/app", 
    entry: { 
     app: "./main" 
    }, 
    resolve: { 
     extensions: ['', '.js', '.ts', '.css', '.scss'] 
    }, 
    output: { 
     path: __dirname + "/dist", 
     sourceMapFilename: "[name].map", 
     filename: "[name].js" 
    }, 
    module: { 
     loaders: [ 
      //https://www.npmjs.com/package/webpack-typescript 
      { 
       test: /\.ts$/, 
       loader: "ts-loader" 
      }, 
      { 
       test: /\.scss$/, 
       loaders: ExtractTextPlugin.extract("style", "css!sass") 
       //loaders: ExtractTextPlugin.extract("style!css!sass") 
      } 
     ], 
     noParse: [ /angular2\/bundles\/.+/ ] 
    }, 
    plugins: [ 
     new webpack.optimize.OccurenceOrderPlugin(true), 
     new ExtractTextPlugin("style.css"), 
     new HtmlWebpackPlugin({ 
      template: "../index.html", 
      inject: "body" 
     }) 
    ], 
    devtool: "source-map" 
}; 

我已经试过了一堆不同选项的提取()调用,但没有运气。任何帮助将不胜感激。

回答

4

而不是使用

loaders: ExtractTextPlugin.extract("style", "css!sass") 

的,你应该使用

loader: ExtractTextPlugin.extract("style", "css!sass") 

代替。

在这种情况下,错误不是特别具有描述性。

+0

感谢@bebraw,那就是诀窍..现在你指出我的错误是有道理的。 – Bob