forked from ShuyunFF2E/ccms-components
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
43 lines (35 loc) · 954 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
38
39
40
41
42
/**
* @author Kuitos
* @homepage https://github.com/kuitos/
* @since 2015-11-30
*/
var path = require('path');
var jsonServer = require('json-mock-kuitos');
var webpack = require('webpack');
var config = require('./webpack-dev.config');
var app = jsonServer.create();
var compiler = webpack(config);
app.use(require('webpack-dev-middleware')(compiler, {
noInfo: false,
stats: {
colors: true,
cached: false
},
publicPath: config.output.publicPath
}));
// redirect root location to demos index
app.use(/\/$/, function(req, res) {
res.redirect('/demos/index.html');
});
app.use(require('webpack-hot-middleware')(compiler));
app.use(jsonServer.defaults({static: path.resolve(__dirname)}));
app.use('/api', jsonServer.proxy('http://localhost', 8989));
const port = 3000;
const host = '0.0.0.0';
app.listen(port, host, function(err) {
if (err) {
console.log(err);
return;
}
console.log(`Listening at http://${host}:${port}\n`);
});