0

由于某种原因,我无法开始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 Hot Client 已启用并正在运行,但更改文件不会导致发生任何更新。我注意到 Webpack 正在重建,但 Webpack Hot Client 什么也没做。

4

1 回答 1

0

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

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

于 2018-07-13T20:42:10.060 回答