add hot reload support
Change-Id: I29cf167e3ec96ffa046d454863f4dbf0eebcd9f4
diff --git a/client/src/index.js b/client/src/index.js
index b39e2f5..f4c1f23 100644
--- a/client/src/index.js
+++ b/client/src/index.js
@@ -3,15 +3,25 @@
import './index.scss';
import App from './App';
//import * as serviceWorker from './serviceWorker';
+const rootEl = document.getElementById('root');
+const render = Component =>
ReactDOM.render(
<React.StrictMode>
- <App />
+ <Component />
</React.StrictMode>,
- document.getElementById('root')
+ rootEl
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
//serviceWorker.unregister();
+render(App)
+if (module.hot) module.hot.accept('./App', () => {
+ try {
+ render(App)
+ } catch (e) {
+ location.reload()
+ }
+})
\ No newline at end of file
diff --git a/client/webpack.config.js b/client/webpack.config.js
index c02de06..6f02eac 100644
--- a/client/webpack.config.js
+++ b/client/webpack.config.js
@@ -1,13 +1,17 @@
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
+const webpack = require('webpack')
module.exports = {
- entry: path.resolve(__dirname, 'src', 'index.js'),
+ entry: ['react-hot-loader/patch',
+ 'webpack-hot-middleware/client',
+ path.resolve(__dirname, 'src', 'index.js')],
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/'
},
+ devtool: 'inline-source-map',
mode: 'development',
module: {
rules: [
@@ -28,6 +32,7 @@
]
},
plugins: [
+ new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'src', 'index.ejs')
})