title: Hot Module Replacement with Webpack, Express & Babel (babel-loader) not working with React Components (Error: Ignored an update to unaccepted module)
body: <p>I am new to React webpack and such and I am trying to implement Hot Module replacement into my workflow.  I am using webpack, express, Babel ES6 with React and I believe I have all the loaders that i need.</p>
  
  <p>I have got HMR working for my CSS files and it updates CSS perfectly but for some reason, when I try and update a React component, I get the following error and have to refresh the page in order to see my changes. I've been struggling the whole day so any assistance would be greatly received! The error I get is the following (my code follows afterward):</p>
  
  <pre><code>&gt;Ignored an update to unaccepted module 28 -&gt; 17
  &gt;
  [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 https://webpack.js.org/concepts/hot-module-replacement/ for more details.
  &gt;
  [HMR]  - ./app/scripts/libs/index.js
  </code></pre>
  
  <p><strong>index.js (Entry)</strong></p>
  
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import style from 'css/main.css';
  import Sections from 'components/Sections/index.js';
  
  
  ReactDOM.render(
      &lt;div&gt;
          &lt;h2&gt;Hek&lt;/h2&gt; 
          &lt;Sections&gt;&lt;/Sections&gt;
      &lt;/div&gt;, 
  
      document.getElementById('app')
  )
  
  console.log('check for me');
  </code></pre>
  
  <p><strong>index.js (Sections Component)</strong></p>
  
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  
  export class Sections extends React.Component{
      render(){
          return(
              &lt;div&gt;
                  &lt;h1&gt;Yo yo yo wahts&lt;/h1&gt;
                  &lt;p&gt;hlfgdfd&lt;/p&gt;
              &lt;/div&gt;
          )
      }
  }
  
  module.exports = Sections;
  </code></pre>
  
  <p><strong>BuildScript.js</strong>
      'use strict';</p>
  
  <pre><code>var express = require('express'); //get the express module
  var webpack = require('webpack');
  var webpackDevMiddleware = require('webpack-dev-middleware');
  var webpackHotMiddleware = require('webpack-hot-middleware');
  
  var app = express(); //create a new instance of that class
  var config = require('../../../webpack.config.js');
  var compiler = webpack(config);
  
  
  app.use(webpackDevMiddleware(compiler, {
      publicPath: config.output.publicPath
  }));
  
  app.use(webpackHotMiddleware(compiler));
  
  app.listen(3000, function () {
      // return console.log('Example app listening on port 3000!');
  });
  </code></pre>
  
  <p><strong>Webpack.config.js</strong></p>
  
  <pre><code>const path = require('path');
  const HtmlWebpackPlugin = require('html-webpack-plugin');
  const CleanWebpackPlugin = require('clean-webpack-plugin');
  const webpack = require('webpack');
  const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
  
  module.exports = {
      entry: [ 'webpack-hot-middleware/client' , './app/scripts/libs/index.js'], //Can also use "main" property
      output: {
          path: path.resolve(__dirname, 'tmp'), //resolves the absolute path 
          filename: '[name].bundle.js', //
          publicPath: '/'
      },
      devtool: 'inline-source-map',
      resolve:{
          alias: {
              components: path.resolve(__dirname, 'app/scripts/components'),
              fonts: path.resolve(__dirname,  'app/scripts/fonts'),
              images: path.resolve(__dirname,  'app/images'),
              sass: path.resolve(__dirname,  'app/styles/sass'),
              css: path.resolve(__dirname,  'app/styles/css')
          }
      },
      module: {
          rules: [
              {
                  test: /\.css$/,
                  use: ['style-loader', 'css-loader'] //to use the CSS imported - in your index.js file you 
              },
              {
                  test: /\.scss$/,
                  use: ['style-loader', 'css-loader', 'sass-loader']
              },
              {
                  test: /\.(jpg|png|svg|gif)$/,
                  use:['file-loader']
              },            
              {
                  test: /\.(woff|woff2|eot|ttf|otf)$/,
                  use: ['file-loader']
              },
              {
                  test: /\.js$/,
                  loader: 'babel-loader',
                  query: {
                      presets: ['env', 'react']
                  }
  
              }
          ]
      },
      plugins:[
          new HtmlWebpackPlugin({
              title: 'African Banker Awards 2018',
              template: './app/scripts/libs/template.ejs',
              inject: 'body'
          }), 
          new CleanWebpackPlugin(['tmp']),
          new webpack.HotModuleReplacementPlugin()
          //new UglifyJsPlugin()
      ]
    };
  </code></pre>
  
  <p><strong>NPM Packages Installed</strong></p>
  
  <pre><code>  "devDependencies": {
      "babel-cli": "^6.26.0",
      "babel-core": "^6.26.0",
      "babel-loader": "^7.1.2",
      "babel-plugin-syntax-dynamic-import": "^6.18.0",
      "babel-preset-env": "^1.6.1",
      "babel-preset-react": "^6.24.1",
      "clean-webpack-plugin": "^0.1.17",
      "css-loader": "^0.28.7",
      "eslint": "^4.10.0",
      "file-loader": "^1.1.5",
      "html-webpack-plugin": "^2.30.1",
      "install": "^0.10.1",
      "npm": "^5.5.1",
      "sass-loader": "^6.0.6",
      "style-loader": "^0.19.0",
      "uglifyjs-webpack-plugin": "^1.1.4",
      "webpack": "^3.10.0",
      "webpack-dev-middleware": "^2.0.1",
      "webpack-hot-middleware": "^2.21.0"
    }
  }
  </code></pre>