Skip to content

Commit 4fdc10d

Browse files
committed
feat: 支持更多配置
1 parent 7a74be2 commit 4fdc10d

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mpbuild",
3-
"version": "1.4.2",
3+
"version": "1.4.3",
44
"description": "",
55
"main": "src/index.js",
66
"scripts": {

src/plugin/projectConfigPlugin.js

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ const chalk = require('chalk');
1010

1111
module.exports = class ProjectConfigPlugin {
1212
constructor(options) {
13-
this.options = Object.assign(
14-
{},
15-
{
16-
projectname: '',
17-
appId: ''
18-
},
19-
options
20-
);
13+
this.options = {
14+
15+
projectname: '',
16+
appId: '',
17+
...options
18+
};
2119
}
2220

2321
apply(mpb) {
@@ -27,52 +25,59 @@ module.exports = class ProjectConfigPlugin {
2725
const projectConfigFile = path.join(distDir, 'project.config.json');
2826
const isExist = fs.existsSync(projectConfigFile);
2927
if (!isExist) {
30-
console.log(chalk.gray('[ProjectConfigPlugin]: '), chalk.blue('project.config.json 不存在,重新生成'));
28+
console.log(
29+
chalk.gray('[ProjectConfigPlugin]: '),
30+
chalk.blue('project.config.json 不存在,重新生成')
31+
);
3132
await fse.outputJson(projectConfigFile, {
3233
description: '项目配置文件',
3334
packOptions: {
34-
ignore: []
35+
ignore: [],
3536
},
3637
setting: {
3738
urlCheck: false,
38-
es6: false,
39-
postcss: true,
40-
minified: false,
41-
newFeature: true
39+
es6: false,
40+
postcss: true,
41+
minified: false,
42+
newFeature: true,
43+
...this.options.setting
4244
},
4345
compileType: 'miniprogram',
44-
libVersion: '2.0.3',
46+
libVersion: this.options.libVersion || '2.10.4',
4547
appid: this.options.appId,
4648
projectname: this.options.projectname,
4749
scripts: {
4850
beforeCompile: '',
4951
beforePreview: '',
50-
beforeUpload: ''
52+
beforeUpload: '',
5153
},
5254
condition: {
5355
search: {
5456
current: -1,
55-
list: []
57+
list: [],
5658
},
5759
conversation: {
5860
current: -1,
59-
list: []
61+
list: [],
6062
},
6163
plugin: {
6264
current: -1,
63-
list: []
65+
list: [],
6466
},
6567
game: {
66-
list: []
68+
list: [],
6769
},
6870
miniprogram: {
6971
current: 31,
70-
list: []
71-
}
72-
}
72+
list: [],
73+
},
74+
},
7375
});
74-
}else{
75-
console.log(chalk.gray('[ProjectConfigPlugin]: '), chalk.blue('project.config.json 存在,不需要重新生成'));
76+
} else {
77+
console.log(
78+
chalk.gray('[ProjectConfigPlugin]: '),
79+
chalk.blue('project.config.json 存在,不需要重新生成')
80+
);
7681
}
7782
return Promise.resolve();
7883
});

0 commit comments

Comments
 (0)