【问题标题】:Unable to get webpack-hot-client to reload on file change无法让 webpack-hot-client 在文件更改时重新加载
【发布时间】:2018-07-13 20:36:50
【问题描述】:

由于某种原因,我无法让webpack-hot-loader 工作。这就是我的使用方式:

const bodyParser = require('body-parser')
const cors = require('cors')
const express = require('express')
const webpack = require('webpack')
const webpackDevMiddleware = require('webpack-dev-middleware')
const webpackHotClient = require('webpack-hot-client')

const config = require('config')
const errorOnHtml = require('scripts/utils/httpServer/errorOnHtml')
const paths = require('scripts/utils/paths')
const runEntrypoint = require('scripts/utils/runEntrypoint')
const trackRequest = require('scripts/utils/httpServer/azureAppInsights')
const webpackDevMiddlewareConfig = require('config/webpackMiddleware/dev')
const { webpackDevelopClientConfig } = require('config/webpack')

const webpackCompiler = webpack(webpackDevelopClientConfig)

webpackHotClient(webpackCompiler)

const httpServerConfig = express()

httpServerConfig
.use(
  webpackDevMiddleware(
    webpackCompiler,
    {
      publicPath: (
        webpackDevelopClientConfig
        .publicPath
      ),
    }
  )
)

.all('*', runEntrypoint('app.server'))

module.exports = () => httpServerConfig

另一个函数实际上在不同的文件中运行 Express 服务器。

我看到 Webpack Hot Client 已启用并正在运行,但更改文件不会导致发生任何更新。我注意到 Webpack 正在重建,但 Webpack Hot Client 什么也没做。

【问题讨论】:

    标签: webpack webpack-hmr webpack-hot-client


    【解决方案1】:

    看来我需要设置一个自定义端口。

    此处未显示附加到此 Express 实例的另一个 WebSocket 服务器。如果不指定自定义端口,webpack-hot-client 似乎无法正常运行。

    【讨论】:

      猜你喜欢
      • 2018-11-26
      • 2018-12-03
      • 2016-05-23
      • 2023-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-27
      相关资源
      最近更新 更多