From 5a1c20d0a653452a9fae35e644c13fc7172f3602 Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 22 Oct 2017 21:06:39 -0500 Subject: [PATCH] [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 --- build/bin/build-style-entry.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/build/bin/build-style-entry.js b/build/bin/build-style-entry.js index e4f61af5a..a760de350 100644 --- a/build/bin/build-style-entry.js +++ b/build/bin/build-style-entry.js @@ -9,22 +9,18 @@ const dependencyTree = require('dependency-tree'); components.forEach(componentName => { const libDir = path.resolve(__dirname, '../../lib'); - const dependencies = analyzeDependencies(componentName, libDir); - const styleDir = path.join(libDir, componentName, '/style'); - const content = dependencies.map(component => `require('../../vant-css/${component}.css');`); - fs.outputFileSync(path.join(styleDir, './index.js'), content.join('\n')); + const content = analyzeDependencies(componentName, libDir).map(component => `require('../../vant-css/${component}.css');`); + fs.outputFileSync(path.join(libDir, componentName, './style/index.js'), content.join('\n')); }); // Analyze component dependencies function analyzeDependencies(componentName, libDir) { - const dependencies = dependencyTree({ + const checkList = ['base']; + search(dependencyTree({ directory: libDir, filename: path.resolve(libDir, componentName, 'index.js'), filter: path => path.indexOf('vant/lib/') !== -1 - }) - const checkList = ['base']; - search(dependencies, checkList); - console.log(componentName ,checkList); + }), checkList); return checkList.filter(component => checkComponentHasStyle(component)); } @@ -39,10 +35,5 @@ function search(tree, checkList) { } function checkComponentHasStyle(componentName) { - const cssPath = path.join(__dirname, '../../lib/vant-css/', `${componentName}.css`); - return fs.existsSync(cssPath); -} - -function toPascal(str) { - return ('_' + str).replace(/[_.-](\w|$)/g, (_, x) => x.toUpperCase()); + return fs.existsSync(path.join(__dirname, '../../lib/vant-css/', `${componentName}.css`)); }