mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[bugfix] popup style missing when build style entry (#231)
* [bugfix] Checkbox border render error in weixin browser * [bugfix] TreeSelect dependency path error * [bugfix] Swipe should clear autoplay timer when destroyed * [bugfix] Optimize component dependency analyze when build style entry * merge * update yarn.lock * update README.md * update README.md * update README.md * update README.md * update README.md * [Doc] add more badges in README.md * update README.md * [bugfix] Address & Contact list style * fix: contact test cases * [bugfix] popup style missing when build style entry
This commit is contained in:
parent
0884cad227
commit
5a1c20d0a6
@ -9,22 +9,18 @@ const dependencyTree = require('dependency-tree');
|
|||||||
|
|
||||||
components.forEach(componentName => {
|
components.forEach(componentName => {
|
||||||
const libDir = path.resolve(__dirname, '../../lib');
|
const libDir = path.resolve(__dirname, '../../lib');
|
||||||
const dependencies = analyzeDependencies(componentName, libDir);
|
const content = analyzeDependencies(componentName, libDir).map(component => `require('../../vant-css/${component}.css');`);
|
||||||
const styleDir = path.join(libDir, componentName, '/style');
|
fs.outputFileSync(path.join(libDir, componentName, './style/index.js'), content.join('\n'));
|
||||||
const content = dependencies.map(component => `require('../../vant-css/${component}.css');`);
|
|
||||||
fs.outputFileSync(path.join(styleDir, './index.js'), content.join('\n'));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Analyze component dependencies
|
// Analyze component dependencies
|
||||||
function analyzeDependencies(componentName, libDir) {
|
function analyzeDependencies(componentName, libDir) {
|
||||||
const dependencies = dependencyTree({
|
const checkList = ['base'];
|
||||||
|
search(dependencyTree({
|
||||||
directory: libDir,
|
directory: libDir,
|
||||||
filename: path.resolve(libDir, componentName, 'index.js'),
|
filename: path.resolve(libDir, componentName, 'index.js'),
|
||||||
filter: path => path.indexOf('vant/lib/') !== -1
|
filter: path => path.indexOf('vant/lib/') !== -1
|
||||||
})
|
}), checkList);
|
||||||
const checkList = ['base'];
|
|
||||||
search(dependencies, checkList);
|
|
||||||
console.log(componentName ,checkList);
|
|
||||||
return checkList.filter(component => checkComponentHasStyle(component));
|
return checkList.filter(component => checkComponentHasStyle(component));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,10 +35,5 @@ function search(tree, checkList) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function checkComponentHasStyle(componentName) {
|
function checkComponentHasStyle(componentName) {
|
||||||
const cssPath = path.join(__dirname, '../../lib/vant-css/', `${componentName}.css`);
|
return fs.existsSync(path.join(__dirname, '../../lib/vant-css/', `${componentName}.css`));
|
||||||
return fs.existsSync(cssPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
function toPascal(str) {
|
|
||||||
return ('_' + str).replace(/[_.-](\w|$)/g, (_, x) => x.toUpperCase());
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user