Webpack HMR无法更新

问题描述

在客户端上更改某些文件后的浏览器控制台:

// browser path @ http://localhost:3000/settings/

[HMR] bundle rebuilding
[HMR] bundle rebuilt in 950ms
[HMR] Checking for updates on the server...
[HMR] Update check Failed: Error: Manifest request to /90250042517446ecd3ba.hot-update.json timed out.
    at XMLHttpRequest.request.onreadystatechange (http://localhost:3000/app.js:42:16)

GET http://localhost:3000/90250042517446ecd3ba.hot-update.json net::ERR_CONNECTION_REFUSED
Uncaught (in promise) Error: Manifest request to /90250042517446ecd3ba.hot-update.json timed out.
    at XMLHttpRequest.request.onreadystatechange (bootstrap:41)

GET http://localhost:3000/__webpack_hmr net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)

我的package.json脚本

"dev": "npm run lint && tsc-watch --onSuccess \"ts-node ./node_modules/moleculer/bin/moleculer-runner.js --envfile ./deploy/.env --hot --repl --config moleculer.config.ts ./services/**/*.service.ts\"",

我的webpack配置:

// webpack.config.js

module.exports = {
  .......,entry: {
    app: [
      'webpack-hot-middleware/client?reload=true',path.join(__dirname,'frontend','main.tsx'),],},output: {
    path: path.join(__dirname,'public'),filename: '[name].js',publicPath: '/',}

在后端

// services/api.service.ts

import devMiddleware from 'webpack-dev-middleware';
import hotMiddleware from 'webpack-hot-middleware';

// route middlewares @ GET /settings

    ............
            use: [
              compression(),devMiddleware(compiler,{
                noInfo: true,publicPath: config.output.publicPath,headers: { 'Access-Control-Allow-Origin': '*' },}),// Webpack hot replacement
              hotMiddleware(compiler,{
                log: broker.logger.info,ApiGateway.serveStatic('./public'),.............

似乎每次我在客户端上进行更改时,服务器也会重新启动,我认为情况并非如此

请让我知道是否需要提供其他相关信息

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)