Skip to content

Commit 8fdce7d

Browse files
committed
fix(build): fix merge strategy for array in configs
1 parent 90e4ca4 commit 8fdce7d

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

packages/mars-build/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"gulp-util": "^3.0.8",
2222
"less": "^3.9.0",
2323
"lodash.merge": "^4.6.1",
24+
"lodash.mergewith": "^4.6.2",
2425
"md5": "^2.2.1",
2526
"mkdirp": "^0.5.1",
2627
"node-sass": "^4.11.0",

packages/mars-build/src/compiler/sfc/parser.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
const File = require('./File');
99
const {parseHTML} = require('../../helper/html-parser');
1010
const {parseComponent} = require('vue-template-compiler/build');
11-
const merge = require('lodash.merge');
11+
// const merge = require('lodash.merge');
12+
const merge = require('../../helper/util').merge;
1213

1314
/**
1415
* pre parse SFC content to convert <script type="config"> => <config>

packages/mars-build/src/helper/util.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
* @author zhangwentao
44
*/
55

6+
const mergeWith = require('lodash.mergewith');
7+
8+
function customizerReplaceArray(objValue, srcValue) {
9+
if (Array.isArray(objValue)) {
10+
return srcValue;
11+
}
12+
}
13+
14+
function getMerge(customizer) {
15+
return (object, sources) => mergeWith(object, sources, customizer);
16+
}
17+
18+
exports.merge = getMerge(customizerReplaceArray);
19+
620
/**
721
* Create a cached version of a pure function.
822
*/

packages/mars-build/src/scripts/getConfig.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
const path = require('path');
77
const fs = require('fs-extra');
8-
const merge = require('lodash.merge');
8+
// const merge = require('lodash.merge');
9+
const merge = require('../helper/util').merge;
910
const getDefaultConf = require('./defaultConfig');
1011

1112
function getProjectConfig(target) {

packages/mars-cli/lib/build.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ async function build(cmd) {
5050
}
5151
});
5252
});
53-
5453
}
5554

5655
module.exports = (...args) =>

0 commit comments

Comments
 (0)