Skip to content

feture: 添加自定义配置 output.jsonpFunction 名称的能力 #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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