-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
137 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Created by ximing on 2019-04-08. | ||
*/ | ||
const del = require('del'); | ||
const chalk = require('chalk'); | ||
|
||
module.exports = class CleanMbpPlugin { | ||
constructor(options) { | ||
this.options = Object.assign( | ||
{}, | ||
{ | ||
path: [] | ||
}, | ||
options | ||
); | ||
} | ||
|
||
apply(mpb) { | ||
mpb.hooks.start.tapPromise('CleanMbpPlugin', async () => { | ||
if (Array.isArray(this.options.path) && this.options.path.length > 0) { | ||
console.log( | ||
chalk.gray('[CleanMbpPlugin]: '), | ||
chalk.blue('删除文件:'), | ||
this.options.path | ||
); | ||
await del(this.options.path); | ||
} | ||
return Promise.resolve(); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* Created by ximing on 2019-04-08. | ||
*/ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const fse = require('fs-extra'); | ||
const chalk = require('chalk'); | ||
|
||
// const Asset = require('../mpb/asset.js'); | ||
|
||
module.exports = class ProjectConfigPlugin { | ||
constructor(options) { | ||
this.options = Object.assign( | ||
{}, | ||
{ | ||
projectname: '', | ||
appId: '' | ||
}, | ||
options | ||
); | ||
} | ||
|
||
apply(mpb) { | ||
mpb.hooks.start.tapPromise('ProjectConfigPlugin', async () => { | ||
// 模拟一个文件出来 | ||
const distDir = path.resolve(process.cwd(), mpb.dest); | ||
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 不存在,重新生成') | ||
); | ||
await fse.outputJson(projectConfigFile, { | ||
description: '项目配置文件', | ||
packOptions: { | ||
ignore: [] | ||
}, | ||
setting: { | ||
urlCheck: false, | ||
es6: false, | ||
postcss: true, | ||
minified: false, | ||
newFeature: true | ||
}, | ||
compileType: 'miniprogram', | ||
libVersion: '2.0.3', | ||
appid: this.options.appId, | ||
projectname: this.options.projectname, | ||
scripts: { | ||
beforeCompile: '', | ||
beforePreview: '', | ||
beforeUpload: '' | ||
}, | ||
condition: { | ||
search: { | ||
current: -1, | ||
list: [] | ||
}, | ||
conversation: { | ||
current: -1, | ||
list: [] | ||
}, | ||
plugin: { | ||
current: -1, | ||
list: [] | ||
}, | ||
game: { | ||
list: [] | ||
}, | ||
miniprogram: { | ||
current: 31, | ||
list: [] | ||
} | ||
} | ||
}); | ||
} else { | ||
console.log( | ||
chalk.gray('[ProjectConfigPlugin]: '), | ||
chalk.blue('project.config.json 存在,不需要重新生成') | ||
); | ||
} | ||
return Promise.resolve(); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters