1 | const ChainedMap = require('./ChainedMap');
|
2 | const ChainedSet = require('./ChainedSet');
|
3 |
|
4 | module.exports = class extends ChainedMap {
|
5 | constructor(parent) {
|
6 | super(parent);
|
7 |
|
8 | this.allowedHosts = new ChainedSet(this);
|
9 |
|
10 | this.extend([
|
11 | 'bonjour',
|
12 | 'clientLogLevel',
|
13 | 'color',
|
14 | 'compress',
|
15 | 'contentBase',
|
16 | 'disableHostCheck',
|
17 | 'filename',
|
18 | 'headers',
|
19 | 'historyApiFallback',
|
20 | 'host',
|
21 | 'hot',
|
22 | 'hotOnly',
|
23 | 'https',
|
24 | 'info',
|
25 | 'inline',
|
26 | 'lazy',
|
27 | 'noInfo',
|
28 | 'open',
|
29 | 'openPage',
|
30 | 'overlay',
|
31 | 'pfx',
|
32 | 'pfxPassphrase',
|
33 | 'port',
|
34 | 'proxy',
|
35 | 'progress',
|
36 | 'public',
|
37 | 'publicPath',
|
38 | 'quiet',
|
39 | 'setup',
|
40 | 'socket',
|
41 | 'staticOptions',
|
42 | 'stats',
|
43 | 'stdin',
|
44 | 'useLocalIp',
|
45 | 'watchContentBase',
|
46 | 'watchOptions',
|
47 | ]);
|
48 | }
|
49 |
|
50 | toConfig() {
|
51 | return this.clean(
|
52 | Object.assign(
|
53 | {
|
54 | allowedHosts: this.allowedHosts.values(),
|
55 | },
|
56 | this.entries() || {}
|
57 | )
|
58 | );
|
59 | }
|
60 |
|
61 | merge(obj, omit = []) {
|
62 | if (!omit.includes('allowedHosts') && 'allowedHosts' in obj) {
|
63 | this.allowedHosts.merge(obj.allowedHosts);
|
64 | }
|
65 |
|
66 | return super.merge(obj, ['allowedHosts']);
|
67 | }
|
68 | };
|