提交 005c8dd5 编写于 作者: fxy060608's avatar fxy060608

fix(mp): merge manifest.json into app.json (#3035)

上级 43892230
export * from './jsonFile'
export { AppJson } from './types'
export { parseMiniProgramPagesJson } from './pages'
export { mergeMiniProgramAppJson, parseMiniProgramPagesJson } from './pages'
export { parseMiniProgramProjectJson } from './project'
......@@ -6,6 +6,7 @@ import { validatePages } from '../pages'
import { AppJson, NetworkTimeout, PageWindowOptions } from './types'
import { parseTabBar, parseWindowOptions } from './utils'
import { normalizePath } from '../../utils'
import { isMiniProgramProjectJsonKey } from './project'
interface ParsePagesJsonOptions {
debug?: boolean
......@@ -25,6 +26,20 @@ export function parseMiniProgramPagesJson(
return parsePagesJson(jsonStr, platform, options)
}
export function mergeMiniProgramAppJson(
appJson: Record<string, any>,
platformJson: Record<string, any> = {}
) {
Object.keys(platformJson).forEach((name) => {
if (
!isMiniProgramProjectJsonKey(name) &&
!['usingComponents', 'optimization'].includes(name)
) {
appJson[name] = platformJson[name]
}
})
}
function parsePagesJson(
jsonStr: string,
platform: UniApp.PLATFORM,
......
......@@ -24,6 +24,10 @@ const projectKeys = [
'cloudbaseRoot',
]
export function isMiniProgramProjectJsonKey(name: string) {
return projectKeys.includes(name)
}
export function parseMiniProgramProjectJson(
jsonStr: string,
platform: UniApp.PLATFORM,
......
......@@ -12,6 +12,7 @@ import {
addMiniProgramPageJson,
addMiniProgramAppJson,
findChangedJsonFiles,
mergeMiniProgramAppJson,
} from '@dcloudio/uni-cli-shared'
import { virtualPagePath } from './entry'
import { UniMiniProgramPluginOptions } from '../plugin'
......@@ -61,6 +62,9 @@ export function uniPagesJsonPlugin(
resolvedConfig,
nvuePages.map((pagePath) => pagePath + options.style.extname)
)
mergeMiniProgramAppJson(appJson, manifestJson[process.env.UNI_PLATFORM])
if (options.json?.formatAppJson) {
options.json.formatAppJson(appJson, manifestJson, pageJsons)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册