2

Just like title, when I add publicPath property in output, the HMR(Hot module replacement) not work, and when I remove it, It can work correctly. And below is my webpack configuration:

output: {
    path: path.resolve(__dirname, './dist'),
    filename: '[name].js',
    libraryTarget: 'umd',
    // globalObject: 'window',
    publicPath: `http://localhost:${PORT_NUMBER}` // this line, when I add, HMR not work
  },
  devServer: {
    hot: true,
    historyApiFallback: true,
    // 设置本地服务端口
    port: PORT_NUMBER,
    headers: {
      'Access-Control-Allow-Origin': '*',
    },

Who can help me solve it, Thanks a lot.

my webpack version is : "^5.72.0", and webpack-dev-server version is "^4.8.1"

0 Answers0