Skip to content

Commit 682a07d

Browse files
committed
Switch to react-hot-loader v3
1 parent 7da01af commit 682a07d

File tree

6 files changed

+85
-239
lines changed

6 files changed

+85
-239
lines changed

.babelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"react"
55
],
66
"plugins": [
7+
"react-hot-loader/babel",
78
"transform-class-properties",
89
"transform-decorators",
910
"transform-object-rest-spread",

client/index.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Provider } from 'react-redux';
55
import { Router } from 'react-router';
66
import { browserHistory } from 'react-router';
77
import { syncHistoryWithStore } from 'react-router-redux';
8+
import { AppContainer } from 'react-hot-loader';
89
import configureStore from 'store';
910
import routes from 'routes';
1011

@@ -23,10 +24,22 @@ const initialState = window.__INITIAL_STATE__;
2324
const store = configureStore(initialState);
2425
const history = syncHistoryWithStore(browserHistory, store);
2526

26-
// Render the app!
27-
ReactDOM.render(
28-
<Provider store={store}>
29-
<Router history={history} routes={routes} />
30-
</Provider>,
31-
rootElement
32-
);
27+
const render = (routes) => {
28+
ReactDOM.render(
29+
<Provider store={store}>
30+
<AppContainer>
31+
<Router history={history} routes={routes} />
32+
</AppContainer>
33+
</Provider>,
34+
rootElement
35+
);
36+
};
37+
38+
render(routes);
39+
40+
if (module.hot) {
41+
module.hot.accept('../common/js/routes', () => {
42+
const newRoutes = require('../common/js/routes').default;
43+
render(newRoutes);
44+
});
45+
}

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,13 @@
9595
},
9696
"devDependencies": {
9797
"babel-eslint": "7.2.3",
98-
"better-npm-run": "^0.0.15",
99-
"debug": "^2.6.0",
98+
"better-npm-run": "0.0.15",
99+
"debug": "2.6.0",
100100
"eslint": "3.19.0",
101101
"eslint-loader": "1.7.1",
102102
"eslint-plugin-react": "6.10.3",
103103
"nodemon": "1.11.0",
104104
"react-transform-catch-errors": "1.0.2",
105-
"react-transform-hmr": "1.0.4",
106105
"redbox-react": "1.3.6",
107106
"redux-devtools": "3.4.0",
108107
"redux-devtools-dock-monitor": "1.1.2",
@@ -143,12 +142,12 @@
143142
"include-media": "1.4.9",
144143
"isomorphic-fetch": "2.2.1",
145144
"json-loader": "0.5.4",
146-
"lodash": "4.17.4",
147145
"mocha": "3.3.0",
148146
"node-sass": "4.5.2",
149147
"postcss-loader": "1.3.3",
150148
"react": "15.5.4",
151149
"react-dom": "15.5.4",
150+
"react-hot-loader": "next",
152151
"react-redux": "5.0.4",
153152
"react-router": "4.1.1",
154153
"react-router-redux": "4.0.8",

webpack/base.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import path from 'path';
22
import webpack from 'webpack';
33
import mapValues from 'lodash/mapValues';
4-
import autoprefixer from 'autoprefixer';
54
import isomorphicConfig from './isomorphic';
65
import IsomorphicPlugin from 'webpack-isomorphic-tools/plugin';
76
import { OUTPUT_PATH, ASSET_HOST, RESOLVE_PATHS } from './constants';
@@ -48,12 +47,13 @@ export default {
4847
test: /\.jsx$|\.js$/,
4948
exclude: /node_modules/,
5049
use: [
50+
'babel-loader',
5151
{
5252
loader: 'eslint-loader',
5353
options: {
5454
configFile: './.eslintrc',
5555
}
56-
}
56+
},
5757
]
5858
},
5959
{

webpack/development.hot.js

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
/* eslint-disable no-console */
22
import { DEV_SERVER_PORT, DEV_SERVER_HOSTNAME, DEV_SERVER_HOST_URL } from './constants';
33
import WebpackDevServer from 'webpack-dev-server';
4+
import path from 'path';
45
import webpack from 'webpack';
56
import baseConfig from './base';
67
import packageJson from '../package.json';
78

89
// Webpack Entry Point for dev server
910
const entry = [
11+
'react-hot-loader/patch',
1012
'webpack-dev-server/client?' + DEV_SERVER_HOST_URL,
1113
'webpack/hot/only-dev-server'
1214
];
1315

1416
// Additional plugins
1517
const plugins = [
1618
new webpack.HotModuleReplacementPlugin(),
17-
new webpack.NoErrorsPlugin(),
19+
new webpack.NoEmitOnErrorsPlugin(),
1820
new webpack.NamedModulesPlugin()
1921
];
2022

@@ -50,26 +52,6 @@ const loaders = [
5052
'postcss-loader',
5153
'sass-loader'
5254
]
53-
},
54-
{
55-
test: /\.jsx$|\.js$/,
56-
loader: 'babel-loader',
57-
exclude: /node_modules/,
58-
// use react-transform to hot reload modules when hot is specified
59-
query: {
60-
plugins: [
61-
['react-transform', {
62-
transforms: [{
63-
transform: 'react-transform-hmr',
64-
imports: ['react'],
65-
locals: ['module']
66-
}, {
67-
transform: 'react-transform-catch-errors',
68-
imports: ['react', 'redbox-react']
69-
}]
70-
}]
71-
]
72-
}
7355
}
7456
];
7557

0 commit comments

Comments
 (0)