我所看到的所有示例都在进行热模块替换时将条目作为字符串数组。
当您有多个条目时,它是如何工作的?我尝试了以下操作,但仍然收到了Uncaught exception: HMR is disabled
消息。
Webpack配置:
module.exports = {
context: path.join(staticPath, "js"),
entry: {
hot: 'webpack/hot/only-dev-server',
main: './main.js',
admin: './admin.js',
vendor: './vendor.js',
devServerClient: 'webpack-dev-server/client?http://localhost:4000'
},
output: {
filename: "[name].bundle.js",
path: path.join(staticPath, "js/"),
publicPath: "http://localhost:4000/static/bundles/"
},
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loaders: ["react-hot", "babel-loader"] },
{ test: /\.json$/, loader: "json" }
]
},
resolve: {
extensions: ['', '.js', '.json']
},
plugins: [
new webpack.optimize.CommonsChunkPlugin('shared', 'shared.bundle.js'),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new BundleTracker({ path: rootPath, filename: './webpack-stats.json' })
]
}