Skip to content

Commit

Permalink
fix: Fall back to default merging in mergeWithRules (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoforsalmin authored Nov 12, 2020
1 parent 250503f commit 08c88c1
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function mergeWithRules(rules: Rules) {
return mergeWithRule({ currentRule, a, b });
}

return [];
return undefined;
}
});
}
Expand Down
73 changes: 73 additions & 0 deletions test/merge-with-rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,79 @@ describe("Merge with rules", function() {
);
});

it("should merge #157", function() {
const base = {
entry: "demo",
module: {
rules: [
{
test: /\.scss$/,
loaders: ["css-loader"]
},
{
test: /\.css$/,
loaders: ["style-loader"]
}
]
},
plugins: [
{ name: 'StylelintPlugin' }
]
};
const development = {
module: {
rules: [
{
test: /\.scss$/,
loaders: ["style-loader"]
},
{
test: /\.less$/,
loaders: ["css-loader"]
}
]
},
plugins: [
{ name: "MiniCssExtractPlugin" }
]
};
const result = {
entry: "demo",
module: {
rules: [
{
test: /\.scss$/,
loaders: ["style-loader"]
},
{
test: /\.css$/,
loaders: ["style-loader"]
},
{
test: /\.less$/,
loaders: ["css-loader"]
}
]
},
plugins: [
{ name: "StylelintPlugin" },
{ name: "MiniCssExtractPlugin" }
]
};

assert.deepStrictEqual(
mergeWithRules({
module: {
rules: {
test: CustomizeRule.Match,
loaders: CustomizeRule.Replace
}
}
})(base, development),
result
);
});

it("should merge with a parser loader", function() {
const defaultConfig = {
module: {
Expand Down

0 comments on commit 08c88c1

Please sign in to comment.