diff --git a/client/src/index.js b/client/src/index.js index e355ec7..d8721c4 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -21,7 +21,19 @@ window.store = store // bootstrap state store.dispatch(fetchMe()); -ReactDOM.render( - , - document.getElementById('root') -); \ No newline at end of file +// renderApp function for hot reloading +const renderApp = App => { + const NextApp = require('./components/App').default; + ReactDOM.render( + , + document.getElementById('root') + ); +} + +// hot loading +if (module.hot) { + module.hot.accept("./components/App", () => { renderApp(App) }) +} + +// initial render +renderApp(App) diff --git a/webpack.config.js b/webpack.config.js index 2e37da7..2d31ecd 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,6 @@ 'use strict'; -require('dotenv').config() +require('dotenv').config(); var webpack = require('webpack'); var path = require('path'); @@ -14,6 +14,7 @@ var config = { output: { path: BUILD_DIR, filename: 'app.js', + publicPath: `http://localhost:${process.env.WEBPACK_PORT}/`, }, module: { loaders : [ @@ -30,7 +31,8 @@ var config = { ] }, plugins: [ - new webpack.HotModuleReplacementPlugin() + new webpack.HotModuleReplacementPlugin(), + new webpack.NamedModulesPlugin() ], devServer: {