mirror of https://github.com/webpack/webpack.git
parent
d7518494c1
commit
8bc25f65e6
|
@ -146,7 +146,7 @@ RuleSet.normalizeRule = function(rule, refs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rule.loader && rule.loaders)
|
if(rule.loader && rule.loaders)
|
||||||
throw new Error("Provided loader and loaders for rule");
|
throw new Error(RuleSet.buildErrorMessage(rule, new Error("Provided loader and loaders for rule (use only one of them)")));
|
||||||
|
|
||||||
var loader = rule.loaders || rule.loader;
|
var loader = rule.loaders || rule.loader;
|
||||||
if(typeof loader === "string" && !rule.options && !rule.query) {
|
if(typeof loader === "string" && !rule.options && !rule.query) {
|
||||||
|
@ -160,10 +160,12 @@ RuleSet.normalizeRule = function(rule, refs) {
|
||||||
query: rule.query
|
query: rule.query
|
||||||
});
|
});
|
||||||
} else if(loader && (rule.options || rule.query)) {
|
} else if(loader && (rule.options || rule.query)) {
|
||||||
throw new Error("options/query cannot be used with loaders");
|
throw new Error(RuleSet.buildErrorMessage(rule, new Error("options/query cannot be used with loaders (use options for each array item)")));
|
||||||
} else if(loader) {
|
} else if(loader) {
|
||||||
checkUseSource("loaders");
|
checkUseSource("loaders");
|
||||||
newRule.use = RuleSet.normalizeUse(loader);
|
newRule.use = RuleSet.normalizeUse(loader);
|
||||||
|
} else if(rule.options || rule.query) {
|
||||||
|
throw new Error(RuleSet.buildErrorMessage(rule, new Error("options/query provided without loader (use loader + options)")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rule.use) {
|
if(rule.use) {
|
||||||
|
@ -186,13 +188,13 @@ RuleSet.normalizeRule = function(rule, refs) {
|
||||||
|
|
||||||
function checkUseSource(newSource) {
|
function checkUseSource(newSource) {
|
||||||
if(useSource && useSource !== newSource)
|
if(useSource && useSource !== newSource)
|
||||||
throw new Error("Rule can only have one result source (provided " + newSource + " and " + useSource + ")");
|
throw new Error(RuleSet.buildErrorMessage(rule, new Error("Rule can only have one result source (provided " + newSource + " and " + useSource + ")")));
|
||||||
useSource = newSource;
|
useSource = newSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkResourceSource(newSource) {
|
function checkResourceSource(newSource) {
|
||||||
if(resourceSource && resourceSource !== newSource)
|
if(resourceSource && resourceSource !== newSource)
|
||||||
throw new Error("Rule can only have one resource source (provided " + newSource + " and " + resourceSource + ")");
|
throw new Error(RuleSet.buildErrorMessage(rule, new Error("Rule can only have one resource source (provided " + newSource + " and " + resourceSource + ")")));
|
||||||
resourceSource = newSource;
|
resourceSource = newSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue