0

I'm implementing a Hot Module Replacement with Webpack in my project, which uses Node(v4.4.4)/Hapi(v8.0.0) as a server. The way I thought I could get it working was by using a plugin in my server file, which is shown below:

`var compiler = new require('webpack')(webpackConfig.default);
 var assets = { noInfo: false, publicPath: webpackConfig.default.output.publicPath };
 var hot = { reload: true, noInfo: true };`

server.register({
    register: require('hapi-webpack-plugin'),
    options: {
      compiler, assets, hot
    }
  },function(error) {
    if (error) {
      return console.error(error);
    }

    server.start(function() {
      if (process.env.CONFIG_WINSTON === 'on') {
        logger.info('Hapi', server.version, server.info.uri);
      } else {
        console.log('Hapi', server.version, server.info.uri);
      }
    });
  });`

In my webpack.config.js, I'm using my entry like this:

entry: [ 'webpack-hot-middleware/client?http://localhost:8080&reload=true', './webpack_common/src/scripts/main.js', ],

I have also added this plugin in my webpack.config.js:

new webpack.HotModuleReplacementPlugin(),

And finally I have already installed the packages:

"webpack": "^2.2.1", "webpack-dev-middleware": "^1.10.1", "webpack-dev-server": "^2.4.4", "webpack-hot-middleware": "^2.17.1", "hapi-webpack-plugin": "^2.0.0",

With all this setup, I could get my HMR working fine with Sass, which means, it is rebuilding and updating my browser. However, when I change any javascript, I see log messages saying everything went well (the bundle was rebuilt),

`

[HMR] bundle rebuilding client.js?4b20:207 
[HMR] bundle rebuilt in 11952ms process-update.js:27 
[HMR] Checking for updates on the server... process-update.js:100 
[HMR] Updated modules:
A list of updated modules comes here...

[HMR] App is up to date.`

but I don't see any updates in my browser. If I manually refresh my browser, than the updates display fine. I tested with Chrome, Firefox and Safari, but none of them seems to work. I have searched through many other questions in foruns, but with no luck. Anyone has any clue on what I may need to do?

eduardo
  • 119
  • 1
  • 3

0 Answers0