Skip to content

Commit c596813

Browse files
authored
Merge pull request #15 from mpvue/feature/jsonpFunction
feture: 添加自定义配置 output.jsonpFunction 名称的能力
2 parents 384539a + 89cb75e commit c596813

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,36 @@
88

99
bug 或者交流建议等请反馈到 [mpvue/issues](https://github.com/Meituan-Dianping/mpvue/issues)
1010

11+
## example
12+
```
13+
const mpvueSimple = require('mpvue-simple')
14+
15+
// build for signel Page
16+
mpvueSimple.build()
17+
18+
// or more options
19+
mpvueSimple.build({
20+
output: 'mp-pages',
21+
pageName: 'login'
22+
})
23+
24+
// or more options
25+
mpvueSimple.build({
26+
output: {
27+
path: 'mp-pages',
28+
jsonpFunction: 'webpackJsonpMpvue' // optional config
29+
},
30+
pageName: 'login'
31+
})
32+
33+
// maybe you want to do something after building
34+
mpvueSimple.build() // => Promise
35+
.then(() => console.log('mpvue build success'))
36+
.catch(err => throw new Error(err))
37+
```
38+
39+
## changelog
40+
41+
#### `1.0.17`
42+
- 加入可选配置项 `output.jsonpFunction`,mpvue 打包构建后会在 `manifest.js` 中生生成全局的模块加载器函数 `global.webpackJsonp`,为防止和其它构建工具引起命名冲突,该默认函数名可在 output 配置中指定,示例如上。
43+

config/argv.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,14 @@ function mergeArgvConfig (config) {
132132

133133
// 输出文件夹
134134
if (argvOutput) {
135-
const assetsRoot = path.resolve(argvOutput)
135+
let outputPath = argvOutput;
136+
if (typeof argvOutput === 'object') {
137+
outputPath = argvOutput.path;
138+
config.argvConfig.output = Object.assign({}, argvOutput);
139+
delete config.argvConfig.output.path;
140+
}
141+
142+
const assetsRoot = path.resolve(outputPath)
136143
defConfig.assetsRoot = assetsRoot
137144
}
138145

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mpvue-simple",
3-
"version": "1.0.15",
3+
"version": "1.0.17",
44
"description": "辅助 mpvue 快速开发 Page / Component 级小程序页面的工具",
55
"main": "index.js",
66
"bin": "bin/mpvue-simple",

0 commit comments

Comments
 (0)