normalizeFallback.js 885 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = normalizeFallback;
  6. var _loaderUtils = _interopRequireDefault(require("loader-utils"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. function normalizeFallback(fallback, originalOptions) {
  9. let loader = 'file-loader';
  10. let options = {};
  11. if (typeof fallback === 'string') {
  12. loader = fallback;
  13. const index = fallback.indexOf('?');
  14. if (index >= 0) {
  15. loader = fallback.substr(0, index);
  16. options = _loaderUtils.default.parseQuery(fallback.substr(index));
  17. }
  18. }
  19. if (fallback !== null && typeof fallback === 'object') {
  20. ({
  21. loader,
  22. options
  23. } = fallback);
  24. }
  25. options = Object.assign({}, originalOptions, options);
  26. delete options.fallback;
  27. return {
  28. loader,
  29. options
  30. };
  31. }