Typescript 打字脚本和HMR不工作
我用Typescript、ReactJS和Webpack构建了前端应用程序。Typescript 打字脚本和HMR不工作,typescript,webpack,webpack-hmr,Typescript,Webpack,Webpack Hmr,我用Typescript、ReactJS和Webpack构建了前端应用程序。 我正在尝试启用HMR。 这些是开始脚本 "build": "NODE_ENV=production $(npm bin)/webpack --watch", "dev": "$(npm bin)/nodemon --exec \"$(npm bin)/ts-node\" ./server/server.ts || npm run build", 这是我的ts加载器 { test: /\.tsx?$/, loader:
我正在尝试启用HMR。
这些是开始脚本
"build": "NODE_ENV=production $(npm bin)/webpack --watch",
"dev": "$(npm bin)/nodemon --exec \"$(npm bin)/ts-node\" ./server/server.ts || npm run build",
这是我的ts加载器
{ test: /\.tsx?$/, loader: 'awesome-typescript-loader' }
和我的开发服务器配置
if (NODE_ENV === 'development') {
let webpack = require('webpack')
const webpackConfig = require('../webpack.config')
const compiler = webpack(webpackConfig)
app.use(require('webpack-dev-middleware')(compiler, {
noInfo: true, publicPath: webpackConfig.output.publicPath
}))
app.use(require('webpack-hot-middleware')(compiler))
}
我无法克服这个错误
[HMR] The following modules couldn't be hot updated: (Full reload needed)
This is usually because the modules which have changed (and their parents) do not know how to hot reload themselves. See http://webpack.github.io/docs/hot-module-replacement-with-webpack.html for more details.
具有相同的问题,并通过添加
react hot loader
修复了该问题,可以使用npm install--save dev react hot loader
安装该问题
您的配置应如下所示:
{test://\.tsx?$/,加载程序:['react-hot','awesome typescript loader']}