由于某种原因,我无法开始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 什么也没做。