3

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-loader です

{ 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.
4

1 に答える 1