-
Notifications
You must be signed in to change notification settings - Fork 6
/
.doolrc.js
45 lines (44 loc) · 1009 Bytes
/
.doolrc.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
const join = require('path').join;
const mockjs = require('mockjs');
const jsonServer = require('json-server');
module.exports = {
publicPath: 'http://localhost:8000/',
entry: {
app: './src/index.js'
},
commons: {
name: 'vendor',
chunks: 'initial',
test: /node_modules[\\/](.*)\.js$/i,
enforce: true
},
babelPlugins: ['@babel/transform-runtime'],
devServer: {
historyApiFallback: {
rewrites: [{
from: /./,
to: '/demo/index.html'
}]
},
before(app) {
const data = mockjs.mock({
'users|100': [{
'id|+1': 1,
name: '@cname',
email: '@email',
'address|1-20': 20
}],
'cities|20': [{
'id|+1': 1,
name: '@city(true)'
}]
});
const router = jsonServer.router(data);
const middlewares = jsonServer.defaults({
static: join(__dirname, 'demo')
});
app.use(middlewares);
app.use('/api', router);
}
}
};