-
Notifications
You must be signed in to change notification settings - Fork 453
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (29 loc) · 995 Bytes
/
server.js
File metadata and controls
37 lines (29 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var express = require('express');
var app = express();
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var buildConfig = require('./webpack.config')
var host = 'react-koans-etherealite.c9users.io';
var webpackPort = 8081;
var webpackHostname= `${host}:${webpackPort}`;
var config = buildConfig(webpackHostname);
app.get('/app.js', function (req, res) {
res.redirect(`//${webpackHostname}/build/app.js`);
});
app.get('/', function (req, res) {
res.sendFile(__dirname + '/build/index.html');
});
app.use(express.static(__dirname + '/build/stylesheets'));
new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: true,
noInfo: true,
historyApiFallback: true
}).listen(webpackPort, process.env.IP, function (err, result) {
if (err) {
console.log(err);
}
});
var server = app.listen(8080, function () {
console.log('Listening at http://localhost:%s', server.address().port);
});