-
Notifications
You must be signed in to change notification settings - Fork 48
/
server.js
57 lines (52 loc) · 1.5 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var useExpress = (process.env.NODE_ENV == 'PRODUCTION' || process.env.NODE_ENV == 'STAGING' || process.env.NODE_ENV == 'PROTOTYPE');
var host = '0.0.0.0';
var port = 3009;
if (useExpress) {
var express = require('express');
var path = require('path');
var app = express();
var static_path = path.join(__dirname, 'dist');
app.use(express.static(static_path))
.get('/*', function (req, res) {
res.sendFile('index.html', {
root: static_path
});
}).listen(process.env.PORT || 3009, function (err) {
if (err) { console.log(err) };
console.log(`>>> Listening at ${ host }:${ port }`);
});
} else {
var config = require('./webpack.config');
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
new WebpackDevServer(webpack(config), {
contentBase: './dist',
publicPath: config.output.publicPath,
compress: true,
hot: true,
quiet: false,
noInfo: false,
historyApiFallback: {
index: 'index.html',
rewrites: [
{
from: /^\/auth\/activate\/.*$/,
to: function() {
return 'index.html';
}
},
{
from: /^\/auth\/reset\/.*$/,
to: function() {
return 'index.html';
}
}
]
},
open: true,
stats: { colors: true }
}).listen(port, host, function (err, result) {
if (err) { console.log(err) }
console.log(`>>> Listening at ${ host }:${ port }`);
});
}