Skip to content

Commit 7136575

Browse files
committed
initial commit
0 parents  commit 7136575

File tree

8 files changed

+90
-0
lines changed

8 files changed

+90
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
*npm-debug.log
3+
*.DS_Store

app/scripts/app.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react/addons';
2+
3+
let Hello = React.createClass({
4+
render() {
5+
return(
6+
<h1>Hello, {this.props.name}!</h1>
7+
)
8+
}
9+
});
10+
11+
React.render(<Hello name='World' />, document.body);

app/styles/base.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
h1 {
2+
font-family: helvetica;
3+
font-weight: 100;
4+
}

package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "react-node-example",
3+
"version": "0.0.1",
4+
"description": "an example for deploying a node/react app to heroku",
5+
"main": "server.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"start": "NODE_ENV=production node server.js",
9+
"postinstall": "webpack -p --config ./webpack.config.js"
10+
},
11+
"author": "",
12+
"license": "ISC",
13+
"dependencies": {
14+
"babel-core": "^5.8.25",
15+
"babel-loader": "^5.3.2",
16+
"css-loader": "^0.19.0",
17+
"express": "^4.13.3",
18+
"file-loader": "^0.8.4",
19+
"jsx-loader": "^0.13.2",
20+
"react": "^0.13.3",
21+
"style-loader": "^0.12.4",
22+
"webpack": "^1.12.2"
23+
}
24+
}

public/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<link rel="stylesheet" type="text/css" href="./styles/base.css">
6+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
7+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
8+
<title>Node + React</title>
9+
</head>
10+
<body></body>
11+
<script src="app.js"></script>
12+
</html>

public/styles/base.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
h1 {
2+
font-family: helvetica;
3+
font-weight: 100;
4+
}

server.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var path = require('path');
2+
var express = require('express');
3+
4+
var app = express();
5+
var PORT = process.env.PORT || 8080
6+
7+
app.use(express.static(path.join(__dirname, 'public')));
8+
9+
app.get('/', function(request, response) {
10+
response.sendFile(__dirname + '/public/index.html')
11+
});
12+
13+
app.listen(PORT, function() {
14+
console.log("Server is up and running on port: " + PORT)
15+
});

webpack.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var webpack = require('webpack');
2+
3+
module.exports = {
4+
entry: ['./app/scripts/app.jsx'],
5+
output: {
6+
path: './public',
7+
filename: 'app.js'
8+
},
9+
module: {
10+
loaders: [
11+
{ test: /\.html$/, loader: "file?name=[name].[ext]"} ,
12+
{ test: /\.css$/, loader: 'style!css' },
13+
{ test: /\.js$/, loader: "babel-loader?stage=0", exclude: '/node_modules/' },
14+
{ test: /\.jsx$/, loaders: ['jsx-loader', "babel-loader?stage=0"] }
15+
]
16+
}
17+
};

0 commit comments

Comments
 (0)