持续集成分支
This commit is contained in:
72
bin/build.js
Normal file
72
bin/build.js
Normal file
@@ -0,0 +1,72 @@
|
||||
const axios = require("axios");
|
||||
const {copyFiles, fsExtra} = require("./tools");
|
||||
const manifest = {
|
||||
name: "base-wxcp",
|
||||
description: "企业微信应用",
|
||||
versionName: "1.0.0",
|
||||
versionCode: "100",
|
||||
transformPx: true,
|
||||
h5: {
|
||||
title: "加载中",
|
||||
template: "template.h5.html",
|
||||
router: {
|
||||
mode: "history",
|
||||
base: ""
|
||||
},
|
||||
devServer: {
|
||||
disableHostCheck: true,
|
||||
port: "80",
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: "http://192.168.1.87:9000",
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
"^/api": "/"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
optimization: {
|
||||
preload: true,
|
||||
treeShaking: {
|
||||
enable: true
|
||||
}
|
||||
},
|
||||
sdkConfigs: {
|
||||
maps: {
|
||||
qqmap: {
|
||||
key: "RWWBZ-64BEJ-MVLFJ-FTHLQ-JTR6J-SAB2S"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const generate = (extra = {}) => {
|
||||
return Promise.all([
|
||||
// fsExtra.outputJson('src/common/config.json', extra),
|
||||
fsExtra.outputJson('src/manifest.json', manifest),
|
||||
])
|
||||
}
|
||||
module.exports = id => {
|
||||
return axios.post("http://192.168.1.87:12525/node/custom/detail", null, {
|
||||
params: {id}
|
||||
}).then(res => {
|
||||
if (res?.data?.data) {
|
||||
const {customPath, appList, extra} = res.data.data
|
||||
manifest.h5.router.base = extra.base || ""
|
||||
manifest.h5.publicPath = extra.base || "/"
|
||||
let tasks = []
|
||||
return generate(extra)
|
||||
.then(() => customPath ? copyFiles('src/apps', 'library/project/' + customPath) : fsExtra.emptyDir('src/apps'))
|
||||
.then(() => {
|
||||
appList?.map(e => {
|
||||
if (!/project/.test(e.id))
|
||||
tasks.push({dir: 'src/apps/' + e.name, source: 'library/apps/' + e.name})
|
||||
})
|
||||
return Promise.all([
|
||||
copyFiles("src/components/pages", 'library/components/pages'), ...tasks.map(e => copyFiles(e.dir, e.source))])
|
||||
}).then(() => res.data.data)
|
||||
} else Promise.reject("无法找到项目")
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user