由于某种原因,我无法使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什么也不做。
答案 0 :(得分:0)
似乎我需要设置一个自定义端口。
未显示在此Express实例上的另一个WebSocket服务器。如果未指定自定义端口,似乎webpack-hot-client无法正常运行。