Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@ window.store = store
// bootstrap state
store.dispatch(fetchMe());

ReactDOM.render(
<App store={store} />,
document.getElementById('root')
);
// renderApp function for hot reloading
const renderApp = App => {
const NextApp = require('./components/App').default;
ReactDOM.render(
<NextApp store={store} />,
document.getElementById('root')
);
}

// hot loading
if (module.hot) {
module.hot.accept("./components/App", () => { renderApp(App) })
}

// initial render
renderApp(App)
6 changes: 4 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

require('dotenv').config()
require('dotenv').config();
var webpack = require('webpack');
var path = require('path');

Expand All @@ -14,6 +14,7 @@ var config = {
output: {
path: BUILD_DIR,
filename: 'app.js',
publicPath: `http://localhost:${process.env.WEBPACK_PORT}/`,
},
module: {
loaders : [
Expand All @@ -30,7 +31,8 @@ var config = {
]
},
plugins: [
new webpack.HotModuleReplacementPlugin()
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin()
],

devServer: {
Expand Down