normalizeFallback.js
885 Bytes
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
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = normalizeFallback;
var _loaderUtils = _interopRequireDefault(require("loader-utils"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function normalizeFallback(fallback, originalOptions) {
let loader = 'file-loader';
let options = {};
if (typeof fallback === 'string') {
loader = fallback;
const index = fallback.indexOf('?');
if (index >= 0) {
loader = fallback.substr(0, index);
options = _loaderUtils.default.parseQuery(fallback.substr(index));
}
}
if (fallback !== null && typeof fallback === 'object') {
({
loader,
options
} = fallback);
}
options = Object.assign({}, originalOptions, options);
delete options.fallback;
return {
loader,
options
};
}