options.js 4.12 KB
Newer Older
liang ce committed
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
'use strict';

/* eslint-disable
  global-require,
  multiline-ternary,
  space-before-function-paren
*/
const ADVANCED_GROUP = 'Advanced options:';
const DISPLAY_GROUP = 'Stats options:';
const SSL_GROUP = 'SSL options:';
const CONNECTION_GROUP = 'Connection options:';
const RESPONSE_GROUP = 'Response options:';
const BASIC_GROUP = 'Basic options:';

const options = {
  bonjour: {
    type: 'boolean',
    describe: 'Broadcasts the server via ZeroConf networking on start',
  },
  lazy: {
    type: 'boolean',
    describe: 'Lazy',
  },
  serveIndex: {
    type: 'boolean',
    describe: 'Enables/Disables serveIndex middleware',
    default: true,
  },
  inline: {
    type: 'boolean',
    default: true,
    describe:
      'Inline mode (set to false to disable including client scripts like livereload)',
  },
  progress: {
    type: 'boolean',
    describe: 'Print compilation progress in percentage',
    group: BASIC_GROUP,
  },
  'hot-only': {
    type: 'boolean',
    describe: 'Do not refresh page if HMR fails',
    group: ADVANCED_GROUP,
  },
  stdin: {
    type: 'boolean',
    describe: 'close when stdin ends',
  },
  open: {
    type: 'string',
    describe: 'Open the default browser, or optionally specify a browser name',
  },
  useLocalIp: {
    type: 'boolean',
    describe: 'Open default browser with local IP',
  },
  'open-page': {
    type: 'string',
    describe: 'Open default browser with the specified page',
    requiresArg: true,
  },
  color: {
    type: 'boolean',
    alias: 'colors',
    default: function supportsColor() {
      // Use `require('supports-color').stdout` for supports-color >= 5.0.0.
      // See https://github.com/webpack/webpack-dev-server/pull/1555.
      return require('supports-color').stdout;
    },
    group: DISPLAY_GROUP,
    describe: 'Enables/Disables colors on the console',
  },
  info: {
    type: 'boolean',
    group: DISPLAY_GROUP,
    default: true,
    describe: 'Info',
  },
  quiet: {
    type: 'boolean',
    group: DISPLAY_GROUP,
    describe: 'Quiet',
  },
  'client-log-level': {
    type: 'string',
    group: DISPLAY_GROUP,
    default: 'info',
    describe: 'Log level in the browser (info, warning, error or none)',
  },
  https: {
    type: 'boolean',
    group: SSL_GROUP,
    describe: 'HTTPS',
  },
  http2: {
    type: 'boolean',
    group: SSL_GROUP,
    describe: 'HTTP/2, must be used with HTTPS',
  },
  key: {
    type: 'string',
    describe: 'Path to a SSL key.',
    group: SSL_GROUP,
  },
  cert: {
    type: 'string',
    describe: 'Path to a SSL certificate.',
    group: SSL_GROUP,
  },
  cacert: {
    type: 'string',
    describe: 'Path to a SSL CA certificate.',
    group: SSL_GROUP,
  },
  pfx: {
    type: 'string',
    describe: 'Path to a SSL pfx file.',
    group: SSL_GROUP,
  },
  'pfx-passphrase': {
    type: 'string',
    describe: 'Passphrase for pfx file.',
    group: SSL_GROUP,
  },
  'content-base': {
    type: 'string',
    describe: 'A directory or URL to serve HTML content from.',
    group: RESPONSE_GROUP,
  },
  'watch-content-base': {
    type: 'boolean',
    describe: 'Enable live-reloading of the content-base.',
    group: RESPONSE_GROUP,
  },
  'history-api-fallback': {
    type: 'boolean',
    describe: 'Fallback to /index.html for Single Page Applications.',
    group: RESPONSE_GROUP,
  },
  compress: {
    type: 'boolean',
    describe: 'Enable gzip compression',
    group: RESPONSE_GROUP,
  },
  port: {
    describe: 'The port',
    group: CONNECTION_GROUP,
  },
  'disable-host-check': {
    type: 'boolean',
    describe: 'Will not check the host',
    group: CONNECTION_GROUP,
  },
  socket: {
    type: 'String',
    describe: 'Socket to listen',
    group: CONNECTION_GROUP,
  },
  public: {
    type: 'string',
    describe: 'The public hostname/ip address of the server',
    group: CONNECTION_GROUP,
  },
  host: {
    type: 'string',
    default: 'localhost',
    describe: 'The hostname/ip address the server will bind to',
    group: CONNECTION_GROUP,
  },
  'allowed-hosts': {
    type: 'string',
    describe:
      'A comma-delimited string of hosts that are allowed to access the dev server',
    group: CONNECTION_GROUP,
  },
};

module.exports = options;