Skip to content

Commit

Permalink
feat: 支持更多配置
Browse files Browse the repository at this point in the history
  • Loading branch information
ximing committed Sep 21, 2020
1 parent 7a74be2 commit 4fdc10d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mpbuild",
"version": "1.4.2",
"version": "1.4.3",
"description": "",
"main": "src/index.js",
"scripts": {
Expand Down
55 changes: 30 additions & 25 deletions src/plugin/projectConfigPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ const chalk = require('chalk');

module.exports = class ProjectConfigPlugin {
constructor(options) {
this.options = Object.assign(
{},
{
projectname: '',
appId: ''
},
options
);
this.options = {

projectname: '',
appId: '',
...options
};
}

apply(mpb) {
Expand All @@ -27,52 +25,59 @@ module.exports = class ProjectConfigPlugin {
const projectConfigFile = path.join(distDir, 'project.config.json');
const isExist = fs.existsSync(projectConfigFile);
if (!isExist) {
console.log(chalk.gray('[ProjectConfigPlugin]: '), chalk.blue('project.config.json 不存在,重新生成'));
console.log(
chalk.gray('[ProjectConfigPlugin]: '),
chalk.blue('project.config.json 不存在,重新生成')
);
await fse.outputJson(projectConfigFile, {
description: '项目配置文件',
packOptions: {
ignore: []
ignore: [],
},
setting: {
urlCheck: false,
es6: false,
postcss: true,
minified: false,
newFeature: true
es6: false,
postcss: true,
minified: false,
newFeature: true,
...this.options.setting
},
compileType: 'miniprogram',
libVersion: '2.0.3',
libVersion: this.options.libVersion || '2.10.4',
appid: this.options.appId,
projectname: this.options.projectname,
scripts: {
beforeCompile: '',
beforePreview: '',
beforeUpload: ''
beforeUpload: '',
},
condition: {
search: {
current: -1,
list: []
list: [],
},
conversation: {
current: -1,
list: []
list: [],
},
plugin: {
current: -1,
list: []
list: [],
},
game: {
list: []
list: [],
},
miniprogram: {
current: 31,
list: []
}
}
list: [],
},
},
});
}else{
console.log(chalk.gray('[ProjectConfigPlugin]: '), chalk.blue('project.config.json 存在,不需要重新生成'));
} else {
console.log(
chalk.gray('[ProjectConfigPlugin]: '),
chalk.blue('project.config.json 存在,不需要重新生成')
);
}
return Promise.resolve();
});
Expand Down

0 comments on commit 4fdc10d

Please sign in to comment.