forked from pavol-brunclik-m2ms/fragalysis-frontend
-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
37 lines (30 loc) · 895 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
36
37
const path = require('path');
const webpack = require('webpack');
const express = require('express');
const config = require('./webpack.config-dev');
const PORT = 3030;
const app = express();
const compiler = webpack(config);
// Enable CORS for all methods
app.use(function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
next();
});
app.use(
require('webpack-dev-middleware')(compiler, {
publicPath: config.output.publicPath,
hot: true,
stats: { colors: true }
})
);
app.use(require('webpack-hot-middleware')(compiler));
app.get('*', function(req, res) {
res.sendFile(path.join(__dirname, 'index.html'));
});
app.listen(PORT, function(err) {
if (err) {
return console.error(err);
}
console.log(`Listening at http://localhost:${PORT}/`);
});