我正在使用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
`);
};
有更好的方法吗?