From 89cb75ee0db17d320f9de210e33d1328f05bd078 Mon Sep 17 00:00:00 2001 From: hucq Date: Thu, 27 Dec 2018 15:03:51 +0800 Subject: [PATCH] =?UTF-8?q?feture:=20=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E9=85=8D=E7=BD=AE=20output.jsonpFunction=20=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E7=9A=84=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 33 +++++++++++++++++++++++++++++++++ config/argv.js | 9 ++++++++- package.json | 2 +- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d1451d4..56d1267 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,36 @@ bug 或者交流建议等请反馈到 [mpvue/issues](https://github.com/Meituan-Dianping/mpvue/issues)。 +## example +``` +const mpvueSimple = require('mpvue-simple') + +// build for signel Page +mpvueSimple.build() + +// or more options +mpvueSimple.build({ + output: 'mp-pages', + pageName: 'login' +}) + +// or more options +mpvueSimple.build({ + output: { + path: 'mp-pages', + jsonpFunction: 'webpackJsonpMpvue' // optional config + }, + pageName: 'login' +}) + +// maybe you want to do something after building +mpvueSimple.build() // => Promise +.then(() => console.log('mpvue build success')) +.catch(err => throw new Error(err)) +``` + +## changelog + +#### `1.0.17` +- 加入可选配置项 `output.jsonpFunction`,mpvue 打包构建后会在 `manifest.js` 中生生成全局的模块加载器函数 `global.webpackJsonp`,为防止和其它构建工具引起命名冲突,该默认函数名可在 output 配置中指定,示例如上。 + diff --git a/config/argv.js b/config/argv.js index 90e4983..490c39a 100644 --- a/config/argv.js +++ b/config/argv.js @@ -132,7 +132,14 @@ function mergeArgvConfig (config) { // 输出文件夹 if (argvOutput) { - const assetsRoot = path.resolve(argvOutput) + let outputPath = argvOutput; + if (typeof argvOutput === 'object') { + outputPath = argvOutput.path; + config.argvConfig.output = Object.assign({}, argvOutput); + delete config.argvConfig.output.path; + } + + const assetsRoot = path.resolve(outputPath) defConfig.assetsRoot = assetsRoot } diff --git a/package.json b/package.json index cd72060..24e71b8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mpvue-simple", - "version": "1.0.15", + "version": "1.0.17", "description": "辅助 mpvue 快速开发 Page / Component 级小程序页面的工具", "main": "index.js", "bin": "bin/mpvue-simple",