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",