Skip to content
This repository was archived by the owner on Apr 11, 2019. It is now read-only.

Commit a50589a

Browse files
committed
Feat: implement server side rendering with example
1 parent a60cdb9 commit a50589a

File tree

17 files changed

+96
-80
lines changed

17 files changed

+96
-80
lines changed

app/src/components/App/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { bindActionCreators } from 'redux';
33
import { connect } from 'react-redux';
44
import * as actionCreators from './actions';
5-
import { Navbar } from 'components';
5+
import { Navbar } from '../../components';
66

77
const Main = (props) => (
88
<div>

app/src/components/LogoImage/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { PropTypes } from 'react';
2-
32
import styles from './index.module.scss';
43
import cssModules from 'react-css-modules';
54

app/src/components/Navbar/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const Navbar = () => (
2525
<Anchor href="#">
2626
Third
2727
</Anchor>
28-
<Search dropAlign={{ right: 'right'}} />
28+
<Search dropAlign={{ right: 'right' }} />
2929
</Menu>
3030
</Header>
3131
</div>

app/src/containers/FeatureFirstContainer/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { PropTypes, Component } from 'react';
33
import {
44
LogoImage,
55
Header,
6-
} from 'components';
6+
} from '../../components';
77
/* eslint-enable import/no-unresolved */
88
import styles from './index.module.scss';
99
import cssModules from 'react-css-modules';

app/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import React from 'react';
33
/* eslint-enable */
44
import { render } from 'react-dom';
55
import RouterApp from './routes';
6-
import { history } from './store/store';
7-
import { routes } from './utils/routes';
6+
import { history } from './store';
7+
import { routes } from './routes';
88
import { match } from 'react-router';
99
import '../styles/styles.scss';
1010

app/src/reducers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { routerReducer } from 'react-router-redux';
33
import { reducer as formReducer } from 'redux-form';
44

55
// Import all of your reducers here:
6-
import featureComponent from 'containers/FeatureFirstContainer/reducer';
6+
import featureComponent from './containers/FeatureFirstContainer/reducer';
77

88
const rootReducer = combineReducers({
99
// Apply all of the reducers here.

app/src/routes.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { Router, Route, IndexRoute } from 'react-router';
33
import { Provider } from 'react-redux';
44
import store, { history } from './store';
55
/* eslint-disable */
6-
import App from 'components/App';
7-
import * as Pages from 'pages';
6+
import App from './components/App';
87
/* eslint-enable */
98

109
if (typeof module !== 'undefined' && module.require) {

app/src/store.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ if (isDeveloping) {
2929
/* https://github.com/gaearon/redux-devtools */
3030
/* https://medium.com/@meagle/understanding-87566abcfb7a */
3131
const enhancers = [];
32-
const devToolsExtension = window.devToolsExtension;
3332
if (isClient && isDeveloping) {
3433
if (typeof devToolsExtension === 'function') {
34+
const devToolsExtension = window.devToolsExtension;
3535
enhancers.push(devToolsExtension());
3636
}
3737
}
@@ -52,7 +52,8 @@ const store = createStore(
5252
);
5353

5454
/* See: https://github.com/reactjs/react-router-redux/issues/305 */
55-
export const history = syncHistoryWithStore(browserHistory, store);
55+
export const history = isClient ?
56+
syncHistoryWithStore(browserHistory, store) : undefined;
5657

5758
/* Hot reloading of reducers. How futuristic!! */
5859
if (module.hot) {

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"test": {
1515
"plugins": [
1616
[
17-
"babel-plugin-webpack-loaders", {
17+
"babel-plugin-webpack-loaders",
18+
{
1819
"config": "./config/testing/webpack.test.config.js",
1920
"verbose": false
2021
}
@@ -102,6 +103,7 @@
102103
"jest-cli": "^15.1.1",
103104
"json-loader": "^0.5.4",
104105
"minimist": "^1.2.0",
106+
"node-ensure": "0.0.0",
105107
"node-sass": "^3.4.2",
106108
"react": "^15.1.0",
107109
"react-addons-css-transition-group": "^15.2.1",

server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
require('babel-core/register');
2+
require('./server/utils/ignoreAssets');
23
var app = require('./server/app');

0 commit comments

Comments
 (0)