@holajs/plugin-platform-gmump
Version:
GMU小程序平台插件
2 lines (1 loc) • 2.71 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});var e=require("path"),t=require("fs-extra"),o=require("shelljs"),n=require("@tarojs/plugin-platform-weapp");function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var r=i(e),u=i(t),s=i(o);function a(e,t,o,n){return new(o||(o=Promise))((function(i,r){function u(e){try{a(n.next(e))}catch(e){r(e)}}function s(e){try{a(n.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(u,s)}a((n=n.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;let p=!1;function c(e,t){if(e&&t)try{const o="gmuConf.js",n=`module.exports = ${JSON.stringify(e)}`;u.writeFileSync(r.join(t,o),n)}catch(e){console.warn(e)}}exports.default=(e,t)=>{process.argv.indexOf("--debug")>-1&&(e.runOpts.options.isMpDebug=!0);let o="gmu";"gmump"===e.runOpts.options.platform&&(u.emptyDirSync(e.paths.outputPath),e.initialConfig.outputRoot=r.join(e.initialConfig.outputRoot,"src"),e.paths.outputPath=r.join(e.paths.outputPath,"src"),e.initialConfig.gmump&&(o="gmump")),e.registerPlatform({name:"gmump",useConfigName:o,fn({config:o}){return a(this,void 0,void 0,(function*(){e.modifyBuildAssets((({miniPlugin:t})=>{var o,n,i;const s=[],a=(null===(n=null===(o=t.appConfig)||void 0===o?void 0:o.window)||void 0===n?void 0:n.pullDownRefreshIconPath)||"";a&&s.push(a),t.pages.forEach((e=>{const o=t.filesConfig[t.getConfigFilePath(e.name)].content.pullDownRefreshIconPath;o&&s.push(o)})),s.forEach((t=>{const o=r.join(e.paths.sourcePath,t),n=r.join(e.paths.outputPath,t);u.ensureDirSync(n.slice(0,n.lastIndexOf(r.sep))),u.copyFileSync(o,n)})),c(null===(i=t.appConfig)||void 0===i?void 0:i.gmuConfig,e.paths.outputPath)})),e.generateFrameworkInfo(),e.generateProjectConfig({srcConfigName:"project.gmump.json",distConfigName:"../project.json"});const i=new n.Weapp(e,o,t||{});yield i.start()}))}}),e.onBuildFinish((()=>{var t,o,n;const{options:i,config:r}=e.runOpts;if("gmump"===i.platform&&!p){p=!0;const u=e.paths.outputPath.replace(/(\/|\\)src(\/|\\)?$/,"");let a="";if(i.isWatch){const e=(null===(t=null==r?void 0:r.devServer)||void 0===t?void 0:t.port)||3e3;a=(null===(o=null==r?void 0:r.exec)||void 0===o?void 0:o.dev)?r.exec.dev:`light release -wb ${e} ${i.isMpDebug?"--debug":""}`}else a=(null===(n=null==r?void 0:r.exec)||void 0===n?void 0:n.prod)?r.exec.prod:"light release -p";s.exec(`cd ${u} && ${a}`,{async:!0})}}))},exports.generateGmuConf=c;