我的问题是,无论我做什么,我都会得到一个 404,wepack_hmr
而且我一生都无法弄清楚为什么它不可用。
完整的 Webpack 配置
var url = 'http://localhost:3000';
module.exports = {
resolve: {
extensions: ['', '.js']
},
entry: ['webpack-hot-middleware/client','./src/client/js/Kindred'],
devtool: 'cheap-module-source-map',
module: {
loaders:[
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {presets: ['es2015', 'react', 'react-hmre', 'stage-0']}
},
{test: /\.png$/, loader: "url-loader?limit=100000"},
// Images
{test: /\.jpg$/, loader: "file-loader"},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file?name=./font/[name].[ext]'
},
// Stylesheets
{ test: /\.scss$/, loader: ExtractTextPlugin.extract('style',
[
'css?sourceMap&modules&importLoaders=1',
'sass?sourceMap&modules',
]
) },
// Font Definitions
{ test: /\.svg$/, loader: 'url?limit=65000&mimetype=image/svg+xml&name=public/font/[name].[ext]' },
{ test: /\.woff$/, loader: 'url?limit=65000&mimetype=application/font-woff&name=public/font/[name].[ext]' },
{ test: /\.woff2$/, loader: 'url?limit=65000&mimetype=application/font-woff2&name=public/font/[name].[ext]' },
{ test: /\.[ot]tf$/, loader: 'url?limit=65000&mimetype=application/octet-stream&name=public/font/[name].[ext]' },
{ test: /\.eot$/, loader: 'url?limit=65000&mimetype=application/vnd.ms-fontobject&name=public/font/[name].[ext]' }
]
},
sassLoader: {
includePaths: [ 'src/client/scss' ]
},
plugins: process.env.NODE_ENV === 'production' ? [
new ExtractTextPlugin ('app.css', {allChunks: true}),
new webpack.optimize.DedupePlugin (),
new webpack.optimize.OccurrenceOrderPlugin (),
new webpack.optimize.UglifyJsPlugin ()
] : [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin("style.css")
],
devServer: {
hot: true,
contentBase: './public'
},
output: {
path: path.join(__dirname),
publicPath: '/',
filename: 'bundle.js'
}
};
节点cmd运行
webpack-dev-server --inline --history-api-fallback --port 3000
加载页面时
[HMR] Waiting for update signal from WDS...
home:1 GET http://localhost:3000/__webpack_hmr
client:22 [WDS] Hot Module Replacement enabled.
它需要我运行,但不是:/