added test case for loader chaining (#3746)

This commit is contained in:
Tobias Koppers 2017-01-04 18:28:34 +01:00 committed by Sean Larkin
parent b7c1b5c672
commit 5b0a16cea3
5 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1 @@
module.exports = ["abc"];

View File

@ -0,0 +1 @@
module.exports = ["def"];

View File

@ -0,0 +1,16 @@
it("should match rule with multiple loaders in 'loader'", function() {
var abc = require("./abc");
abc.should.be.eql([
"abc",
"?b",
"?a"
]);
});
it("should match rule with multiple loaders in 'loaders'", function() {
var def = require("./def");
def.should.be.eql([
"def",
"?d",
"?c"
]);
});

View File

@ -0,0 +1,8 @@
module.exports = function(source) {
var query = this.query;
if(typeof query === "object" && typeof query.get === "function") {
query = query.get();
}
return source + "\nmodule.exports.push(" + JSON.stringify(query) + ");";
};

View File

@ -0,0 +1,14 @@
module.exports = {
module: {
rules: [
{
resource: /abc\.js$/,
loader: "./loader?a!./loader?b"
},
{
resource: /def\.js$/,
loaders: "./loader?c!./loader?d"
}
]
}
}