-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (29 loc) · 935 Bytes
/
server.js
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
var express = require('express');
var path = require('path');
var webpack = require('webpack');
var app = express();
var isDevelopment = (process.env.NODE_ENV !== 'production');
var static_path = path.join(__dirname, 'static');
var config,
WebpackDevServer;
app.use(express.static(static_path))
.get('/', function (req, res) {
res.sendFile('index.html', {
root: static_path
});
}).listen(process.env.PORT || 8080, function (err) {
if (err) { console.log(err) };
console.log('Listening at localhost:8080');
});
if (isDevelopment) {
config = require('./webpack.config');
WebpackDevServer = require('webpack-dev-server');
new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: true,
historyApiFallback: true
}).listen(3000, 'localhost', function (err, result) {
if (err) { console.log(err) }
console.log('Listening at localhost:3000');
});
}