-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
43 lines (34 loc) · 1.03 KB
/
server.js
File metadata and controls
43 lines (34 loc) · 1.03 KB
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
const express = require('express');
const rewrite = require('express-urlrewrite');
const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const WebpackConfig = require('./webpack.config');
const history = require('connect-history-api-fallback');
const app = express();
app.use(webpackDevMiddleware(webpack(WebpackConfig), {
publicPath: '/public/',
stats: {
colors: true,
chunks: false
}
}));
app.use(history({
disableDotRule: true,
verbose: true
}));
const fs = require('fs');
const path = require('path');
/*fs.readdirSync(__dirname).forEach(file => {
if (fs.statSync(path.join(__dirname, file)).isDirectory()) {
app.use(rewrite('/' + file + '/*', '/' + file + '/index.html'))
}
})*/
app.use(express.static(__dirname));
function handleRedirect(req, res) {
console.log(req);
}
//app.get('*', handleRedirect);
const port = process.env.PORT || 8090;
module.exports = app.listen(port, () => {
console.log(`Server listening on http://localhost:${port}, Ctrl+C to stop`)
});