Skip to content

Instantly share code, notes, and snippets.

@sean-clayton
Last active April 14, 2017 07:46
Show Gist options
  • Save sean-clayton/9163961aefd58aa901b53c39dd64c2c0 to your computer and use it in GitHub Desktop.
Save sean-clayton/9163961aefd58aa901b53c39dd64c2c0 to your computer and use it in GitHub Desktop.
import React from "react";
import {render} from "react-dom";
import App from "./App";
const el = document.getElementById("app");
if (__DEV__) { //
import("react-hot-loader").then(rhl => {
const {AppContainer} = rhl;
render(<AppContainer><App /></AppContainer>, el);
if (module.hot) {
module.hot.accept(["./App.js"], () => {
const NewApp = require("./App").default;
render(<AppContainer><NewApp /></AppContainer>, el);
});
}
});
} else {
render(<App />, el);
}
module.exports = {
entry: {
index: [
"react-hot-loader/patch",
"webpack-dev-server/client?http://0.0.0.0:1337",
"webpack/hot/only-dev-server",
"src/index.js"
]
},
devServer: {
hot: true
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
__DEV__: true,
__PROD__: false
})
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment