41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
/**
|
||
* CLI 构建 app manifest 中 splashscreen.autoclose 恒为 false,打包后补丁修正。
|
||
* HBuilderX 云打包会读取 dist/build/app 或 app-plus 下的 manifest.json。
|
||
*/
|
||
import fs from 'fs'
|
||
import path from 'path'
|
||
import { fileURLToPath } from 'url'
|
||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||
const root = path.resolve(__dirname, '..')
|
||
|
||
const targets = [
|
||
path.join(root, 'dist/build/app/manifest.json'),
|
||
path.join(root, 'dist/build/app-plus/manifest.json')
|
||
]
|
||
|
||
for (const file of targets) {
|
||
if (!fs.existsSync(file)) continue
|
||
const manifest = JSON.parse(fs.readFileSync(file, 'utf8'))
|
||
if (manifest.plus) {
|
||
manifest.plus.splashscreen = {
|
||
...(manifest.plus.splashscreen || {}),
|
||
autoclose: true,
|
||
waiting: false,
|
||
delay: 0
|
||
}
|
||
manifest.plus.renderer = 'webview'
|
||
manifest.plus.compatible = { ignoreVersion: true }
|
||
manifest.plus.distribute = manifest.plus.distribute || {}
|
||
manifest.plus.distribute.google = {
|
||
...(manifest.plus.distribute.google || {}),
|
||
packagename: 'com.jyuan.optical'
|
||
}
|
||
if (manifest.plus['uni-app']) {
|
||
manifest.plus['uni-app'].renderer = 'webview'
|
||
}
|
||
}
|
||
fs.writeFileSync(file, JSON.stringify(manifest, null, 2), 'utf8')
|
||
console.log('[patch-app-manifest] patched', path.relative(root, file))
|
||
}
|