Skip to content

Commit 9ee2cfc

Browse files
committed
feat: replace lodash with webpack-merge
1 parent 68d94b2 commit 9ee2cfc

File tree

3 files changed

+48
-20
lines changed

3 files changed

+48
-20
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
},
5858
"dependencies": {
5959
"deep-for-each": "^3.0.0",
60-
"lodash": "^4.17.21"
60+
"webpack-merge": "^6.0.1"
6161
},
6262
"jest": {
6363
"collectCoverageFrom": [

pnpm-lock.yaml

Lines changed: 42 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/options/default.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
const mergeWith = require("lodash/mergeWith");
3+
const { merge } = require("webpack-merge");
44

55
const gruntOptions = {
66
failOnError: (options) => {
@@ -39,13 +39,6 @@ const webpackDevServerOptions = {
3939
},
4040
};
4141

42-
// eslint-disable-next-line consistent-return
43-
function mergeCustomize(a, b) {
44-
if (Array.isArray(a) && Array.isArray(b)) {
45-
return a.concat(b);
46-
}
47-
}
48-
4942
function mergeOptions(defaultOptions, options, targetOptions) {
5043
if (Array.isArray(targetOptions) && Array.isArray(options)) {
5144
if (targetOptions.length !== options.length) {
@@ -55,21 +48,17 @@ function mergeOptions(defaultOptions, options, targetOptions) {
5548
);
5649
}
5750
return targetOptions.map((opt, index) =>
58-
mergeWith({}, defaultOptions, options[index], opt, mergeCustomize),
51+
merge(defaultOptions, options[index], opt),
5952
);
6053
}
6154

6255
if (Array.isArray(targetOptions)) {
63-
return targetOptions.map((opt) =>
64-
mergeWith({}, defaultOptions, options, opt, mergeCustomize),
65-
);
56+
return targetOptions.map((opt) => merge(defaultOptions, options, opt));
6657
} else if (Array.isArray(options)) {
67-
return options.map((opt) =>
68-
mergeWith({}, defaultOptions, opt, targetOptions, mergeCustomize),
69-
);
58+
return options.map((opt) => merge(defaultOptions, opt, targetOptions));
7059
}
7160

72-
return mergeWith({}, defaultOptions, options, targetOptions, mergeCustomize);
61+
return merge(defaultOptions, options, targetOptions);
7362
}
7463

7564
exports.gruntOptions = gruntOptions;

0 commit comments

Comments
 (0)