Skip to content

Commit 0d5d9d1

Browse files
committed
Add express server.
1 parent 58d0f02 commit 0d5d9d1

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
<body>
77
<div id="root">
88
</div>
9-
<script src="dist/bundle.js"></script>
9+
<script src="bundle.js"></script>
1010
</body>
1111
</html>

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
},
1515
"homepage": "https://github.com/ramesaliyev/ej-react-workshop#readme",
1616
"scripts": {
17-
"build": "webpack"
17+
"build": "webpack",
18+
"server": "node server",
19+
"start": "npm run build && npm run server"
1820
},
1921
"dependencies": {
22+
"express": "^4.15.2",
2023
"webpack": "^2.5.0"
2124
}
2225
}

server.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const path = require('path');
2+
const Express = require('express');
3+
4+
const app = new Express();
5+
const port = 3000;
6+
7+
app.use(Express.static('dist'))
8+
9+
app.get('/', (req, res) => {
10+
res.sendFile(path.join(__dirname, 'index.html'));
11+
});
12+
13+
app.listen(port, () => {
14+
console.log('Server working on http://localhost:' + port);
15+
});

0 commit comments

Comments
 (0)