Skip to content

Commit

Permalink
feat(mp-alipay): custom mini.project.json (dcloudio#3929)
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Oct 18, 2022
1 parent 29b404e commit 23f1c94
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
9 changes: 6 additions & 3 deletions packages/uni-mp-alipay/lib/uni.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const path = require('path')
const { parseJson } = require('@dcloudio/uni-cli-shared/lib/json')
const {
parseJson
} = require('@dcloudio/uni-cli-shared/lib/json')

module.exports = {
options: {
Expand All @@ -17,7 +19,8 @@ module.exports = {
filter: '.sjs'
},
filterTag: 'sjs',
subPackages: true
subPackages: true,
project: 'mini.project.json'
},
copyWebpackOptions (platformOptions, vueOptions) {
const copyOptions = ['mycomponents', 'customize-tab-bar', 'ext.json']
Expand All @@ -35,4 +38,4 @@ module.exports = {

return copyOptions
}
}
}
24 changes: 18 additions & 6 deletions packages/webpack-uni-pages-loader/lib/platforms/mp-alipay.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
const fs = require('fs')
const path = require('path')

const {
parsePages
parsePages,
getPlatformProject
} = require('@dcloudio/uni-cli-shared')

const {
Expand Down Expand Up @@ -84,13 +88,21 @@ module.exports = function (pagesJson, manifestJson) {
if (app.usingComponents) {
updateAppJsonUsingComponents(app.usingComponents)
}
const projectName = getPlatformProject()

const project = Object.assign({
appid: platformJson.appid
})
let project = {}

project.component2 = hasOwn(platformJson, 'component2') ? platformJson.component2 : true
project.enableAppxNg = hasOwn(platformJson, 'enableAppxNg') ? platformJson.enableAppxNg : true
const projectPath = path.resolve(process.env.UNI_INPUT_DIR, projectName)
if (fs.existsSync(projectPath)) {
project = require(projectPath)
} else {
if (platformJson.appid) {
project.appid = platformJson.appid
}

project.component2 = hasOwn(platformJson, 'component2') ? platformJson.component2 : true
project.enableAppxNg = hasOwn(platformJson, 'enableAppxNg') ? platformJson.enableAppxNg : true
}

return [{
name: 'app',
Expand Down

0 comments on commit 23f1c94

Please sign in to comment.