2017-06-09 106 views
0

我想在我的React應用程序中使用Webpack HMR。我的WebPack的配置是這樣的:清單請求上的Webpack HMR超時

var path = require('path'); 
var ExtractTextPlugin = require('extract-text-webpack-plugin'); 
var StyleLintPlugin = require('stylelint-webpack-plugin'); 
var webpack = require('webpack'); 

var extractScss = new ExtractTextPlugin({ filename: '[name].css' }); 
var stylelint = new StyleLintPlugin({ context: './source' }); 

module.exports = { 
    devtool: 'source-map', 
    entry: [ 
    'babel-polyfill', 
    'react-hot-loader/patch', 
    'webpack-dev-server/client?http://localhost:8080', 
    'webpack/hot/only-dev-server', 
    './source/index.js' 
    ], 
    output: { 
    filename: 'index.js', 
    path: path.resolve(__dirname, 'public') 
    }, 
    devServer: { 
    hot: true, 
    contentBase: path.resolve(__dirname, 'public'), 
    publicPath: 'http://localhost:1199/public/', 
    historyApiFallback: true, 
    proxy: { 
     "*": { 
     target: 'http://localhost:1199' 
     } 
    } 
    }, 
    module: { 
    rules: [ 
     { // SCSS 
     test: /\.scss$/, 
     use: extractScss.extract({ 
      use: [ 
      { loader: 'css-loader', options: { sourceMap: true, minimize: true } }, 
      { loader: 'sass-loader', options: { sourceMap: true, includePaths: ['./source/sass'] }}, 
      { loader: 'resolve-url-loader' } 
      ], 
      fallback: 'style-loader' 
     }) 
     }, 
     { // JavaScript 
     test: /\.js$/, 
     use: [ 
      { loader: 'babel-loader', options: { 
      "presets": [["es2015", { "modules": false }], "react" , "stage-0"], 
      "plugins": ["react-hot-loader/babel"] 
      } }, 
      { loader: 'eslint-loader'} 
     ] 
     } 
    ] 
    }, 
    plugins: [ 
    extractScss, 
    stylelint, 
    new webpack.HotModuleReplacementPlugin() 
    ] 
}; 

一切似乎工作,但是當我改變一個文件,控制檯返回

[WDS] App updated. Recompiling... 
[WDS] App hot update... 
[HMR] Checking for updates on the server... 
[HMR] Update failed: Error: Manifest request to bcf31e519ba66d20afbe.hot-update.json timed out. at XMLHttpRequest.request.onreadystatechange (http://localhost:8080/public/index.js:38:22) 

我該怎麼辦?

回答