Skip to content

Commit

Permalink
Merge pull request #5 from Justkant/user-signup-login
Browse files Browse the repository at this point in the history
Fix production build
  • Loading branch information
Justkant committed Oct 7, 2015
2 parents 08bc962 + 754f99a commit 490d9a8
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 23 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
language: node_js

node_js:
- "4.1"
- "4.0"
- "4"

sudo: false

cache:
directories:
- node_modules

before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
2 changes: 1 addition & 1 deletion api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if (config.apiPort) {
console.error(err);
}
console.info('----\n==> 🌎 API is running on port %s', config.apiPort);
console.info('==> 💻 Send requests to http://localhost:%s', config.apiPort);
console.info('==> 💻 Send requests to http://localhost:%s ', config.apiPort);
});
} else {
console.error('==> ERROR: No PORT environment variable has been specified');
Expand Down
21 changes: 12 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Quentin 'Kant' Jaccarino",
"name": "whatashop",
"version": "0.1.0",
"version": "0.1.1",
"description": "Online Shopping Application",
"homepage": "https://github.com/Justkant/WhatAShop#readme",
"license": "MIT",
Expand All @@ -28,6 +28,7 @@
"start-prod": "node ./node_modules/better-npm-run start-prod",
"start-prod-api": "node ./node_modules/better-npm-run start-prod-api",
"build": "webpack --verbose --colors --display-error-details --config webpack/prod.config.js",
"postinstall": "webpack --display-error-details --config webpack/prod.config.js",
"lint": "eslint -c .eslintrc src",
"start-dev": "node ./node_modules/better-npm-run start-dev",
"start-dev-api": "node ./node_modules/better-npm-run start-dev-api",
Expand All @@ -41,6 +42,7 @@
"env": {
"NODE_PATH": "./src",
"NODE_ENV": "production",
"PORT": 3000,
"APIPORT": 3030
}
},
Expand Down Expand Up @@ -89,22 +91,22 @@
"body-parser": "1.14.1",
"express": "4.13.3",
"file-loader": "0.8.4",
"history": "1.12.1",
"history": "1.12.2",
"http-proxy": "1.11.2",
"jsonwebtoken": "^5.4.0",
"lru-memoize": "1.0.0",
"map-props": "1.0.0",
"multireducer": "1.0.0",
"multireducer": "1.0.1",
"piping": "0.3.0",
"pretty-error": "1.2.0",
"query-string": "2.4.2",
"react": "^0.14.0-rc1",
"react": "^0.14.0",
"react-document-meta": "2.0.0-rc2",
"react-dom": "0.14.0-rc1",
"react-dom": "0.14.0",
"react-redux": "3.1.0",
"react-router": "1.0.0-rc1",
"redux": "3.0.2",
"redux-form": "2.0.1",
"redux-form": "2.1.0",
"serialize-javascript": "1.1.2",
"serve-favicon": "2.3.0",
"serve-static": "1.10.0",
Expand All @@ -129,9 +131,10 @@
"eslint-config-airbnb": "0.1.0",
"eslint-loader": "1.0.0",
"eslint-plugin-react": "3.5.1",
"extract-text-webpack-plugin": "^0.8.2",
"json-loader": "0.5.3",
"karma": "0.13.10",
"karma-chrome-launcher": "0.2.0",
"karma-chrome-launcher": "0.2.1",
"karma-cli": "0.1.1",
"karma-firefox-launcher": "0.1.6",
"karma-mocha": "0.2.0",
Expand All @@ -140,7 +143,7 @@
"karma-webpack": "1.7.0",
"mocha": "2.3.3",
"react-a11y": "0.2.6",
"react-addons-test-utils": "0.14.0-rc1",
"react-addons-test-utils": "0.14.0",
"react-hot-loader": "1.3.0",
"react-transform-hmr": "1.0.1",
"redux-devtools": "2.1.5",
Expand All @@ -152,6 +155,6 @@
"webpack-hot-middleware": "2.4.1"
},
"engines": {
"node": "4.0.0"
"node": "4.1.2"
}
}
7 changes: 3 additions & 4 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import 'babel/polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
import createHistory from 'history/lib/createBrowserHistory';
import { createHistory } from 'history';
import createStore from './redux/create';
import ApiClient from './helpers/ApiClient';
import universalRouter from './helpers/universalRouter';
Expand Down Expand Up @@ -43,13 +43,12 @@ history.listenBefore((loc, callback) => {
.then((callback));
});

render(location, history, store);
render(location, history, store, !dest.firstChild);

if (process.env.NODE_ENV !== 'production') {
window.React = React; // enable debugger
const reactRoot = window.document.getElementById('content');

if (!reactRoot || !reactRoot.firstChild || !reactRoot.firstChild.attributes || !reactRoot.firstChild.attributes['data-react-checksum']) {
if (!dest || !dest.firstChild || !dest.firstChild.attributes || !dest.firstChild.attributes['data-react-checksum']) {
console.error('Server-side React render was discarded. Make sure that your initial render does not contain any client-side code.');
}
}
4 changes: 2 additions & 2 deletions src/helpers/Html.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import DocumentMeta from 'react-document-meta';
export default class Html extends Component {
static propTypes = {
assets: PropTypes.object,
component: PropTypes.object,
component: PropTypes.node,
store: PropTypes.object
}

render() {
const {assets, component, store} = this.props;
const content = ReactDOM.renderToString(component);
const content = component ? ReactDOM.renderToString(component) : '';

return (
<html lang="en-us">
Expand Down
7 changes: 3 additions & 4 deletions src/server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Express from 'express';
import React from 'react';
import ReactDOM from 'react-dom/server';
import createLocation from 'history/lib/createLocation';
import { createMemoryHistory } from 'history';
import config from './config';
import favicon from 'serve-favicon';
import httpProxy from 'http-proxy';
Expand Down Expand Up @@ -47,7 +47,7 @@ app.use((req, res) => {
}
const client = new ApiClient(req);
const store = createStore(client);
const location = createLocation(req.path, req.query);
const location = createMemoryHistory().createLocation(req.originalUrl);

universalRouter(location, undefined, store, true)
.then(({component, redirectLocation}) => {
Expand All @@ -65,8 +65,7 @@ app.use((req, res) => {
}
console.error('ROUTER ERROR:', pretty.render(error));
res.send('<!doctype html>\n' +
ReactDOM.renderToString(<Html assets={webpackIsomorphicTools.assets()} component={<div></div>}
store={store}/>));
ReactDOM.renderToString(<Html assets={webpackIsomorphicTools.assets()} store={store}/>));
});
});

Expand Down
4 changes: 3 additions & 1 deletion webpack/prod.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var path = require('path');
var webpack = require('webpack');
var CleanPlugin = require('clean-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var autoprefixer = require('autoprefixer-stylus');
var strip = require('strip-loader');

Expand All @@ -29,7 +30,7 @@ module.exports = {
loaders: [
{test: /\.js$/, exclude: /node_modules/, loaders: [strip.loader('console.log', 'debug'), 'babel']},
{test: /\.json$/, loader: 'json-loader'},
{test: /\.styl$/, loader: 'style-loader!css-loader!stylus-loader'},
{test: /\.styl$/, loader: ExtractTextPlugin.extract('style', 'css-loader!stylus-loader') },
{test: webpackIsomorphicToolsPlugin.regular_expression('images'), loader: 'url-loader?limit=10240'}
]
},
Expand All @@ -47,6 +48,7 @@ module.exports = {
plugins: [
new CleanPlugin([relativeAssetsPath]),

new ExtractTextPlugin('[name]-[chunkhash].css', {allChunks: true}),
new webpack.DefinePlugin({
__CLIENT__: true,
__SERVER__: false,
Expand Down

0 comments on commit 490d9a8

Please sign in to comment.