Windows Users: Code Changes not Causing a Reload?

A student asked:

Just starting your course, and found a small concern that you may want to address. When using Windows 10 console, and npm start, it is sometimes necessary to stop it with Ctrl-C + Y, and then restart it for code changes to "take".

This works, but is an extra step not found in your course. Is there a workaround for Windows 10? Or did I miss a step?

A good workaround for this issue is to make Webpack check for file changes at a given interval. In the webpack.config.js file, look for the devServer property and add this code inside it:

 watchOptions: {
    aggregateTimeout: 300,
    poll: 1000
  }

  // Afterwards, the devServer property 
  // might look like this:
  devServer: {
    historyApiFallback: true,
    contentBase: './',
    watchOptions: {
      aggregateTimeout: 300,
      poll: 1000
    }
  }

The properties inside watchOptions tell Webpack when to rebuild and how often to look for changes:

Previous Post Next Post