DevServer.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. 'after',
  9. 'before',
  10. 'bonjour',
  11. 'clientLogLevel',
  12. 'color',
  13. 'compress',
  14. 'contentBase',
  15. 'disableHostCheck',
  16. 'filename',
  17. 'headers',
  18. 'historyApiFallback',
  19. 'host',
  20. 'hot',
  21. 'hotOnly',
  22. 'http2',
  23. 'https',
  24. 'index',
  25. 'info',
  26. 'inline',
  27. 'lazy',
  28. 'mimeTypes',
  29. 'noInfo',
  30. 'open',
  31. 'openPage',
  32. 'overlay',
  33. 'pfx',
  34. 'pfxPassphrase',
  35. 'port',
  36. 'proxy',
  37. 'progress',
  38. 'public',
  39. 'publicPath',
  40. 'quiet',
  41. 'setup',
  42. 'socket',
  43. 'sockHost',
  44. 'sockPath',
  45. 'sockPort',
  46. 'staticOptions',
  47. 'stats',
  48. 'stdin',
  49. 'useLocalIp',
  50. 'watchContentBase',
  51. 'watchOptions',
  52. 'writeToDisk',
  53. ]);
  54. }
  55. toConfig() {
  56. return this.clean({
  57. allowedHosts: this.allowedHosts.values(),
  58. ...(this.entries() || {}),
  59. });
  60. }
  61. merge(obj, omit = []) {
  62. if (!omit.includes('allowedHosts') && 'allowedHosts' in obj) {
  63. this.allowedHosts.merge(obj.allowedHosts);
  64. }
  65. return super.merge(obj, ['allowedHosts']);
  66. }
  67. };