normalizeOptions.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. // Setup default value
  10. options.contentBasePublicPath = options.contentBasePublicPath || '/';
  11. // normalize transportMode option
  12. if (options.transportMode === undefined) {
  13. options.transportMode = {
  14. server: 'sockjs',
  15. client: 'sockjs',
  16. };
  17. } else {
  18. switch (typeof options.transportMode) {
  19. case 'string':
  20. options.transportMode = {
  21. server: options.transportMode,
  22. client: options.transportMode,
  23. };
  24. break;
  25. // if not a string, it is an object
  26. default:
  27. options.transportMode.server = options.transportMode.server || 'sockjs';
  28. options.transportMode.client = options.transportMode.client || 'sockjs';
  29. }
  30. }
  31. if (!options.watchOptions) {
  32. options.watchOptions = {};
  33. }
  34. }
  35. module.exports = normalizeOptions;