forked from BlueChilli/ChilliSource.Web.FormGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
49 lines (38 loc) · 1.3 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
const path = require( 'path');
const open = require('open');
const express = require('express');
const webpack = require('webpack');
const webpackMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
const webpackConfig = require('./webpack.config');
const config = require('config');
const fs = require('fs');
const https = require('https');
const compiler = webpack(webpackConfig);
const app = express();
const host = process.env.HOST || config.get("host") || 'localhost';
const port = config.get("port") || 443;
const url = 'https://' + host + ":" + port + '/';
app.use(express.static(__dirname + '/'));
const serverOptions = {
publicPath: webpackConfig.output.publicPath,
noInfo: true,
stats: 'errors-only'
};
app.use(webpackMiddleware(compiler, serverOptions));
app.use(webpackHotMiddleware(compiler));
app.get('*', function response(req, res) {
res.sendFile(path.join(__dirname, 'app/index.html'));
});
let key = fs.readFileSync('/SSL/bluechilli.com.key');
let cert = fs.readFileSync('/SSL/bluechilli.com.pem');
let httpsServer = https.createServer({
key: key, cert: cert
}, app);
httpsServer.listen(port, function onStart(err) {
if (err) {
console.log(err);
}
//open(url);
console.info('Listening to => %s in your browser.', url);
});