-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.dev.js
39 lines (35 loc) · 1.01 KB
/
webpack.dev.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
/* eslint-disable */
const { merge } = require('webpack-merge')
const common = require('./webpack.common.js')
const path = require('path')
const mock = require('./dev/api.mock.json')
const fs = require('fs')
const config = {
mode: 'development',
devtool: 'inline-source-map',
devServer: {
static: path.resolve(__dirname, 'public'),
historyApiFallback: true,
compress: true,
open: false,
onAfterSetupMiddleware: function (devServer) {
if (!devServer) {
throw new Error('webpack-dev-server is not defined')
}
devServer.app.get('/metadata/client', function (req, res) {
setTimeout(() => {
res.json(mock)
}, 800)
})
devServer.app.get('/starter.zip', function (req, res) {
fs.readFile(path.resolve('./dev/starter.mock.zip'), (err, data) => {
if (err) return sendError(err, res)
setTimeout(() => {
res.send(data)
}, 800)
})
})
},
},
}
module.exports = merge(common, config)