This repository has been archived by the owner on May 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bs.config.js
62 lines (56 loc) · 1.53 KB
/
bs.config.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
|--------------------------------------------------------------------------
| Browser-sync config file
|--------------------------------------------------------------------------
|
| For up-to-date information about the options:
| http://www.browsersync.io/docs/options/
|
| There are more options than you see here, these are just the ones that are
| set internally. See the website for more info.
|
|
*/
const path = require('path')
const proxyMiddleware = require('http-proxy-middleware')
const config = require('./config')
const viewOptions = config.dev.view
const views = viewOptions && viewOptions.root ? viewOptions.root : path.join(__dirname, './views')
const middlewares = []
const proxyTable = config.dev.proxyTable
// proxy api requests
Object.keys(proxyTable).forEach(function (context) {
let options = proxyTable[context]
if (typeof options === 'string') {
options = { target: options }
}
middlewares.push(proxyMiddleware(context, options))
})
// 添加 view 中间件
if (viewOptions) {
middlewares.push(require('./plugins/bs-view')(viewOptions))
}
module.exports = {
// files: views,
server: {
baseDir: views
},
host: config.dev.host,
port: config.dev.port,
middleware: middlewares,
serveStatic: [
path.join(__dirname, '.')
],
open: config.dev.autoOpenBrowser,
browser: 'default',
// todo: 插件如何阻止 bs 的 reload?
// plugins: [
// {
// module: 'bs-html-injector',
// options: {
// files: views
// }
// }
// ],
reloadDebounce: 2000
}