Skip to content

Commit

Permalink
Merge pull request #15 from mpvue/feature/jsonpFunction
Browse files Browse the repository at this point in the history
feture: 添加自定义配置 output.jsonpFunction 名称的能力
  • Loading branch information
hucq authored Dec 27, 2018
2 parents 384539a + 89cb75e commit c596813
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 配置中指定,示例如上。

9 changes: 8 additions & 1 deletion config/argv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit c596813

Please sign in to comment.