提交 3f9d86ba 编写于 作者: fxy060608's avatar fxy060608

fix(mp): recursive merge platform options

上级 654c5949
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const merge = require('merge')
const { const {
parsePages, parsePages,
...@@ -30,6 +31,21 @@ function defaultCopy (name, value, json) { ...@@ -30,6 +31,21 @@ function defaultCopy (name, value, json) {
json[name] = value json[name] = value
} }
function isPlainObject (a) {
if (a === null) {
return false
}
return typeof a === 'object'
}
function deepCopy (name, value, json) {
if (isPlainObject(value) && isPlainObject(json[name])) {
json[name] = merge.recursive(true, json[name], value)
} else {
defaultCopy(name, value, json)
}
}
const pagesJson2AppJson = { const pagesJson2AppJson = {
globalStyle: function (name, value, json) { globalStyle: function (name, value, json) {
json.window = parseStyle(value) json.window = parseStyle(value)
...@@ -115,7 +131,7 @@ const manifestJson2ProjectJson = { ...@@ -115,7 +131,7 @@ const manifestJson2ProjectJson = {
const platformJson2ProjectJson = { const platformJson2ProjectJson = {
appid: defaultCopy, appid: defaultCopy,
setting: defaultCopy, setting: deepCopy,
miniprogramRoot: defaultCopy, miniprogramRoot: defaultCopy,
cloudfunctionRoot: defaultCopy, cloudfunctionRoot: defaultCopy,
qcloudRoot: defaultCopy, qcloudRoot: defaultCopy,
...@@ -123,9 +139,9 @@ const platformJson2ProjectJson = { ...@@ -123,9 +139,9 @@ const platformJson2ProjectJson = {
compileType: defaultCopy, compileType: defaultCopy,
libVersion: defaultCopy, libVersion: defaultCopy,
projectname: defaultCopy, projectname: defaultCopy,
packOptions: defaultCopy, packOptions: deepCopy,
debugOptions: defaultCopy, debugOptions: deepCopy,
scripts: defaultCopy, scripts: deepCopy,
cloudbaseRoot: defaultCopy cloudbaseRoot: defaultCopy
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册