2017-10-10 126 views
0

当我运行的WebPack一切编译和捆绑,因为它应该,但是当我运行的WebPack-dev的服务器我得到这个错误:的WebPack-dev的服务器配置错误,但作品的WebPack

Invalid configuration object. webpack-dev-server has been initialised using a configuration object that does not match the API schema. 
- configuration has an unknown property 'error'. These properties are valid: 
    object { hot?, hotOnly?, lazy?, bonjour?, host?, allowedHosts?, filename?, publicPath?, port?, socket?, watchOptions?, headers?, clientLogLevel?, overlay?, progress?, key?, cert?, ca?, pfx?, pfxPassphrase?, requestCert?, inline?, disableHostCheck?, public?, https?, contentBase?, watchContentBase?, open?, useLocalIp?, openPage?, features?, compress?, proxy?, historyApiFallback?, staticOptions?, setup?, before?, after?, stats?, reporter?, noInfo?, quiet?, serverSideRender?, index?, log?, warn? } 

我webpack.config .js文件的配置,看起来像这样:

const path = require('path') 
const webpack = require('webpack') 
const HtmlWebpackPlugin = require('html-webpack-plugin') 
const ExtractTextPlugin = require('extract-text-webpack-plugin') 
const CopyWebpackPlugin = require('copy-webpack-plugin') 
const CleanWebpackPlugin = require('clean-webpack-plugin') 

module.exports = { 
    entry: { 
     bundle: path.resolve(__dirname, 'src/index.jsx'), 
    }, 
    output: { 
     publicPath: '/', 
     path: __dirname + '/dist', 
     filename: '[name].[chunkhash].js', 
    }, 
    devtool: 'source-map', 
    resolve: { 
     extensions: ['.js', '.jsx'], 
    }, 
    externals: { 
     'react': 'React', 
     'react-dom': 'ReactDOM', 
    }, 
    devServer: { 
     host: '0.0.0.0', 
     port: 8088, 
     historyApiFallback: true, 
    }, 
    watchOptions: { 
     aggregateTimeout: 1, 
     ignored: /node_modules/, 
    }, 
    module: { 
     loaders: [{ 
      test: /.jsx?$/, 
      loader: 'babel-loader', 
      exclude: /node_modules/, 
      query: { 
       presets: ['es2015', 'react', 'stage-0'], 
       plugins: ['transform-runtime'], 
      }, 
     }, { 
      test: /\.html$/, 
      loader: 'html-loader', 
     }, { 
      test: /\.less$/, 
      use: ExtractTextPlugin.extract({ 
       fallback: 'style-loader', 
       use: 'css-loader!postcss-loader!less-loader', 
      }), 
     }, { 
      test: /\.(png|svg|jpg|ico)$/, 
      loader: 'file-loader?name=./img/[hash].[ext]', 
     }, { 
      test: /\.(ttf|woff|woff2|otf|eot)$/, 
      loader: 'file-loader?name=./fonts/[hash].[ext]', 
     }], 
    }, 
    plugins: [ 
     new CleanWebpackPlugin(['dist'], { 
      root: path.resolve(__dirname), 
      verbrose: true, 
     }), 
     new HtmlWebpackPlugin({ 
      template: path.resolve(__dirname, 'src/index.html'), 
     }), 
     new ExtractTextPlugin({ 
      filename: '[name].[chunkhash].css', 
      allChunks: false, 
     }), 
     new webpack.optimize.CommonsChunkPlugin({ 
      name: 'commons', 
     }), 
    ], 
} 

有在配置上没有“错误”财产和的WebPack工作正常,它只是的WebPack-dev的服务器什么是失败?

有一个错过了什么?谢谢你的任何建议。

回答