过滤来自react-hot-server-middleware的websocket webpack-hot-reloading调用

时间:2018-06-10 20:29:04

标签: reactjs webpack-hot-middleware hot-reload

我正在使用webpack-hot-reloading and react-hot-server-middleware`:

app.use(require('webpack-dev-middleware')(multiCompiler, { serverSideRender: true })); app.use(require('webpack-hot-middleware')(clientCompiler));

但是我的websocket调用正在进入中间件,我有一些不好的代码来过滤掉它们:

export default ({ clientStats }: { clientStats: any }) => async (req: Request, res: Response, next: any) => {
  // TODO: find a better way of filtering websocket hot reloading
  if (some(['sockjs', 'hot-update.json'], part => req.url.indexOf(part) > -1)) {
    next();
    return;
  }

  // render html
`);
};

有更好的方法吗?

0 个答案:

没有答案