Skip to content

Commit aafd7e3

Browse files
committed
Setup Your Server with Node, Express, and Babel
1 parent 0dbaf64 commit aafd7e3

File tree

3 files changed

+5628
-2
lines changed

3 files changed

+5628
-2
lines changed

index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import compression from 'compression';
2+
import express from 'express';
3+
4+
const app = express();
5+
const port = process.env.PORT || 8080;
6+
app.use(compression());
7+
8+
app.use(express.static('./build'));
9+
10+
app.listen(port, (err) => {
11+
if (err) {
12+
console.log(err);
13+
return;
14+
}
15+
console.log(`Server is live at http://localhost:${port}`);
16+
});

package.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,31 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"babel-cli": "^6.23.0",
7+
"babel-preset-es2015": "^6.22.0",
8+
"babel-preset-stage-2": "^6.22.0",
9+
"compression": "^1.6.2",
10+
"express": "^4.15.2",
611
"react": "^15.4.2",
712
"react-dom": "^15.4.2"
813
},
914
"devDependencies": {
15+
"babel-watch": "^2.0.6",
16+
"concurrently": "^3.4.0",
1017
"react-scripts": "0.9.4"
1118
},
19+
"proxy": "http://localhost:8081",
1220
"scripts": {
13-
"start": "react-scripts start",
21+
"bluemix": "babel-node index.js",
22+
"start": "concurrently \"PORT=8080 react-scripts start\" \"PORT=8081 babel-watch index.js\"",
1423
"build": "react-scripts build",
1524
"test": "react-scripts test --env=jsdom",
1625
"eject": "react-scripts eject"
26+
},
27+
"babel": {
28+
"presets": [
29+
"es2015",
30+
"stage-2"
31+
]
1732
}
18-
}
33+
}

0 commit comments

Comments
 (0)