-
Notifications
You must be signed in to change notification settings - Fork 81
/
server.js
38 lines (31 loc) · 878 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
/**
* @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);
var apiPrefix = '';
var filename = process.cwd() + '/src/mock/db.json';
app.use(require('webpack-dev-middleware')(compiler, {
noInfo : false,
stats : {
colors: true,
cached: false
},
publicPath: config.output.publicPath
}));
app.use(require('webpack-hot-middleware')(compiler));
app.use(jsonServer.defaults({static: process.cwd() + '/'}));
app.use(jsonServer.router(apiPrefix, filename));
app.listen(3000, 'localhost', function (err) {
if (err) {
console.log(err);
return;
}
console.log('Listening at http://localhost:3000');
});