0
所以發生的是我那裏有的WebPack甚至沒有刷新頁面重新加載在所有
<h1>Home</h1>
<p>This is the home page!</p>
例如,一個首頁,如果我改變Home
到test
,什麼都不會發生,直到我重新啓動的WebPack(密切的聯繫,重新運行webpack -d)。所以不僅熱重裝不起作用,而且重裝也不起作用。我不知道它是怎麼回事,我認爲我正確地遵循了所有的教程。
我的WebPack配置:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
module.exports = {
entry: [
'webpack-hot-middleware/client',
'./client/src/index.js'
],
output: {
path: path.join(__dirname, 'server', 'static', 'js'),
filename: 'bundle.js'
},
resolve: {
extensions: ['.js', '.jsx', '.json']
},
devServer: {
historyApiFallback: true
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [ 'react-hot-loader/webpack', 'babel-loader' ],
}
]
},
plugins: [
new HtmlWebpackPlugin({
inject: 'body',
filename: 'index.html'
}),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development')
})
]
};
我跑webpack -d
這裏是我的假設是所有我使用,以及重要的封裝:
"babel-preset-node6": "^11.0.0",
"babel-preset-react-hmre": "^1.1.1",
"babel-preset-stage-0": "^6.24.1",
"react-dom": "^15.6.1",
"react-hot-loader": "^3.0.0-beta.7",
"react-redux": "^5.0.5",
"react-router-dom": "^4.1.1",
"react-router-redux": "^4.0.8",
"react-scripts": "^1.0.7",
"react-slick": "^0.14.11",
"redux": "^3.7.0",
"redux-logger": "^3.0.6",
"redux-mock-store": "1.0.2",
"redux-thunk": "^2.2.0",
"sequelize": "^4.1.0",
"sequelize-cli": "^2.7.0",
"webpack": "^3.0.0",
"webpack-dev-server": "^2.4.5",
"webpack-hot-middleware": "^2.18.0",
此外,我收到了另一個我認爲與整體重新加載無關的錯誤,但與熱重新加載有關,如果有人可以提供一些建議,這將會有所幫助:
EventSource's response has a MIME type ("text/html") that is not "text/event-stream". Aborting the connection.