UNPKG

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