[Improvement] extract component common part (#703)

This commit is contained in:
neverland
2018-03-16 17:10:46 +08:00
committed by GitHub
parent f26ad3b912
commit ffd72e5442
81 changed files with 174 additions and 207 deletions
+5 -4
View File
@@ -17,19 +17,20 @@ components.forEach(componentName => {
// Analyze component dependencies
function analyzeDependencies(componentName, libDir) {
const checkList = ['base'];
const whiteList = ['icon', 'loading', 'cell', 'button'];
search(dependencyTree({
directory: libDir,
filename: path.resolve(libDir, componentName, 'index.js'),
filter: path => path.indexOf(`vant${SEP}lib${SEP}`) !== -1
}), checkList);
}), checkList, whiteList);
return checkList.filter(component => checkComponentHasStyle(component));
}
function search(tree, checkList) {
function search(tree, checkList, whiteList) {
tree && Object.keys(tree).forEach(key => {
search(tree[key], checkList);
search(tree[key], checkList, whiteList);
const component = key.split(`${SEP}vant${SEP}lib${SEP}`)[1].replace(`${SEP}index.js`, '').replace(`mixins${SEP}`, '');
if (checkList.indexOf(component) === -1) {
if (checkList.indexOf(component) === -1 && whiteList.indexOf(component) === -1) {
checkList.push(component);
}
});