DevServer.js 1.2 KB

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