Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./server.js
12 changes: 12 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

{
'parser': 'babel-eslint',
'extends': 'airbnb',
'globals': {
'__DEV__': true
},
'rules': {
'react/jsx-quotes': 0,
'jsx-quotes': [2, 'prefer-double']
}
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"devDependencies": {
"autoprefixer": "^6.0.2",
"ava": "^0.11.0",
"babel-eslint": "^4.1.6",
"babel-loader": "^6.2.1",
"babel-plugin-transform-runtime": "^6.4.3",
"babel-preset-es2015": "^6.3.13",
Expand All @@ -39,6 +40,9 @@
"coveralls": "^2.11.2",
"css-loader": "^0.18.0",
"enzyme": "^1.4.0",
"eslint": "^1.10.3",
"eslint-config-airbnb": "^4.0.0",
"eslint-plugin-react": "^3.16.1",
"extract-text-webpack-plugin": "^0.8.2",
"nyc": "^5.3.0",
"postcss-loader": "^0.6.0",
Expand Down
28 changes: 14 additions & 14 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var express = require('express');
var express = require("express");
var app = express();


Expand All @@ -12,26 +12,26 @@ var app = express();
************************************************************/

// Serve application file depending on environment
app.get('/app.js', function(req, res) {
app.get("/app.js", function(req, res) {
if (process.env.PRODUCTION) {
res.sendFile(__dirname + '/build/app.js');
res.sendFile(__dirname + "/build/app.js");
} else {
res.redirect('//localhost:9090/build/app.js');
res.redirect("//localhost:9090/build/app.js");
}
});

// Serve aggregate stylesheet depending on environment
app.get('/style.css', function(req, res) {
app.get("/style.css", function(req, res) {
if (process.env.PRODUCTION) {
res.sendFile(__dirname + '/build/style.css');
res.sendFile(__dirname + "/build/style.css");
} else {
res.redirect('//localhost:9090/build/style.css');
res.redirect("//localhost:9090/build/style.css");
}
});

// Serve index page
app.get('*', function(req, res) {
res.sendFile(__dirname + '/build/index.html');
app.get("*", function(req, res) {
res.sendFile(__dirname + "/build/index.html");
});


Expand All @@ -44,16 +44,16 @@ app.get('*', function(req, res) {
*************************************************************/

if (!process.env.PRODUCTION) {
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.local.config');
var webpack = require("webpack");
var WebpackDevServer = require("webpack-dev-server");
var config = require("./webpack.local.config");

new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: true,
noInfo: true,
historyApiFallback: true
}).listen(9090, 'localhost', function (err, result) {
}).listen(9090, "localhost", function (err, result) {
if (err) {
console.log(err);
}
Expand All @@ -72,5 +72,5 @@ var server = app.listen(port, function () {
var host = server.address().address;
var port = server.address().port;

console.log('Essential React listening at http://%s:%s', host, port);
console.log("Essential React listening at http://%s:%s", host, port);
});
11 changes: 10 additions & 1 deletion src/common/components/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React from 'react';


export default class App extends React.Component {
class App extends React.Component {
static propTypes = {
children: React.PropTypes.element.isRequired,
};
render() {
return (
<div id="container">
Expand All @@ -10,3 +13,9 @@ export default class App extends React.Component {
);
}
}

App.propTypes = {
title: React.PropTypes.string.isRequired,
};

export default App;
16 changes: 7 additions & 9 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,23 @@
*/

// Polyfill
import "babel-polyfill";
import 'babel-polyfill';

// Libraries
import React from "react";
import ReactDOM from "react-dom";
import { Router } from "react-router";
import createBrowserHistory from 'history/lib/createBrowserHistory'
import React from 'react';
import ReactDOM from 'react-dom';
import { Router } from 'react-router';
import createBrowserHistory from 'history/lib/createBrowserHistory';

// Routes
import Routes from './common/components/Routes';

// Base styling
import "./common/base.css";
import './common/base.css';


// ID of the DOM element to mount app on
const DOM_APP_EL_ID = "app";


const DOM_APP_EL_ID = 'app';

// Render the router
ReactDOM.render((
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import styles from "./style.css";
import React from 'react';
import styles from './style.css';


export default class HomePage extends React.Component {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/login/page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import styles from "./style.css";
import React from 'react';
import styles from './style.css';


export default class LoginPage extends React.Component {
Expand Down
16 changes: 8 additions & 8 deletions webpack.local.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {

// Efficiently evaluate modules with source maps
devtool: "eval",
devtool: 'eval',

// Set entry point to ./src/main and include necessary files for hot load
entry: [
"webpack-dev-server/client?http://localhost:9090",
"webpack/hot/only-dev-server",
"./src/main"
'webpack-dev-server/client?http://localhost:9090',
'webpack/hot/only-dev-server',
'./src/main'
],

// This will not actually create a bundle.js file in ./build. It is used
// by the dev server for dynamic hot loading.
output: {
path: __dirname + "/build/",
filename: "app.js",
publicPath: "http://localhost:9090/build/"
path: __dirname + '/build/',
filename: 'app.js',
publicPath: 'http://localhost:9090/build/'
},

// Necessary plugins for hot load
Expand All @@ -41,7 +41,7 @@ module.exports = {
// Transform source code using Babel and React Hot Loader
module: {
loaders: [
{ test: /\.jsx?$/, exclude: /node_modules/, loaders: ["react-hot", "babel-loader?presets[]=es2015,presets[]=react,presets[]=stage-0,plugins[]=transform-runtime"] },
{ test: /\.jsx?$/, exclude: /node_modules/, loaders: ['react-hot', 'babel-loader?presets[]=es2015,presets[]=react,presets[]=stage-0,plugins[]=transform-runtime'] },
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss-loader') }
]
},
Expand Down
8 changes: 4 additions & 4 deletions webpack.production.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ var ExtractTextPlugin = require('extract-text-webpack-plugin');
* This is the Webpack configuration file for production.
*/
module.exports = {
entry: "./src/main",
entry: './src/main',

output: {
path: __dirname + "/build/",
filename: "app.js"
path: __dirname + '/build/',
filename: 'app.js'
},

plugins: [
Expand All @@ -18,7 +18,7 @@ module.exports = {

module: {
loaders: [
{ test: /\.jsx?$/, exclude: /node_modules/, loader: "babel-loader?presets[]=es2015,presets[]=react,presets[]=stage-0,plugins[]=transform-runtime" },
{ test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015,presets[]=react,presets[]=stage-0,plugins[]=transform-runtime' },
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss-loader') }
]
},
Expand Down