重构打包脚本
This commit is contained in:
		| @@ -87,27 +87,29 @@ const init = () => { | ||||
| const generateMain = project => { | ||||
|   const getApps = new Promise(resolve => { | ||||
|     const appLib = path.join(__dirname, project.toString(), 'apps.import.json') | ||||
|  | ||||
|     fsExtra.readJson(appLib, (err, data) => { | ||||
|       chalkTag.info(project + '加载业务应用配置...') | ||||
|       fsExtra.emptyDirSync(`project/${project}/apps`) | ||||
|       let apps = [] | ||||
|       if (data) { | ||||
|         fsExtra.emptyDirSync(`project/${project}/apps`) | ||||
|         chalkTag.info(project + '加载业务应用配置...') | ||||
|         Promise.all([ | ||||
|           findApp(`src/project/${project}`, f => apps.push(f)), | ||||
|           findApp(`project/${project}`, file => { | ||||
|             let reg = new RegExp(/.+(App[^\\\/]+)$/) | ||||
|             if (reg.test(file)) { | ||||
|               data[file.replace(reg, '$1')] = file.replace(reg, '$1') | ||||
|             } | ||||
|             return apps.push(file) | ||||
|           }), | ||||
|           findApp('src/mods', file => apps.push(file)) | ||||
|         ]).then(() => { | ||||
|           Promise.all(Object.keys(data).map(e => { | ||||
|         ]).then(() => Promise.all(Object.keys(data).map(e => { | ||||
|           let app = [...new Set(apps)].find(s => s.indexOf(e) > -1) | ||||
|           if (app) { | ||||
|             return copyFiles(`project/${project}/apps/${e}`, app) | ||||
|           } | ||||
|           })).then(() => { | ||||
|         }))).then(() => { | ||||
|           chalkTag.done(project + '业务应用加载完成') | ||||
|           resolve() | ||||
|         }) | ||||
|         }) | ||||
|  | ||||
|       } else { | ||||
|         chalkTag.done(project + '业务应用无打包') | ||||
|         resolve() | ||||
|   | ||||
| @@ -2,7 +2,8 @@ | ||||
|   "name": "@dvcp-wechat-apps/sanjianxi", | ||||
|   "version": "1.0.0", | ||||
|   "files": [ | ||||
|     "apps" | ||||
|     "apps", | ||||
|     "static" | ||||
|   ], | ||||
|   "dependencies": { | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user