创建多个捆绑Web包热重新加载

时间:2016-05-20 08:39:29

标签: webpack webpack-dev-server

我想使用webpack生成多个热重载包:

对于我做的一个:

 entry: [
        'webpack-hot-middleware/client?reload=true',
        path.join(__dirname, 'app/main.js')
      ],

但是对于多个我没有找到如何使用这一行:'webpack-hot-middleware/client?reload=true',

我试试这个:

entry: {
    //'webpack-hot-middleware/client?reload=true', //This line is not accepted by webpack
    firstbundle : path.join(__dirname, 'client/first.js'),
    secondbundle : path.join(__dirname, 'client/second.js'),
    thirdbundle : path.join(__dirname, 'client/third.js')
  },

我如何添加此行?

1 个答案:

答案 0 :(得分:1)

您应该将weboack-hot-middleware传递给每个条目:

entry: {
    firstbundle : ['webpack-hot-middleware/client?reload=true', path.join(__dirname, 'client/first.js')],
    secondbundle : ['webpack-hot-middleware/client?reload=true', path.join(__dirname, 'client/second.js')],
    thirdbundle : ['webpack-hot-middleware/client?reload=true', path.join(__dirname, 'client/third.js')]
},