You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
944 B

4 years ago
  1. 'use strict';
  2. /* eslint-disable
  3. no-undefined
  4. */
  5. function normalizeOptions(compiler, options) {
  6. // Setup default value
  7. options.contentBase =
  8. options.contentBase !== undefined ? options.contentBase : process.cwd();
  9. // normalize transportMode option
  10. if (options.transportMode === undefined) {
  11. options.transportMode = {
  12. server: 'sockjs',
  13. client: 'sockjs',
  14. };
  15. } else {
  16. switch (typeof options.transportMode) {
  17. case 'string':
  18. options.transportMode = {
  19. server: options.transportMode,
  20. client: options.transportMode,
  21. };
  22. break;
  23. // if not a string, it is an object
  24. default:
  25. options.transportMode.server = options.transportMode.server || 'sockjs';
  26. options.transportMode.client = options.transportMode.client || 'sockjs';
  27. }
  28. }
  29. if (!options.watchOptions) {
  30. options.watchOptions = {};
  31. }
  32. }
  33. module.exports = normalizeOptions;