@@ -9,33 +9,33 @@ const dependencyTree = require('dependency-tree');
99const SEP = path . sep ;
1010
1111components . forEach ( componentName => {
12- const libDir = path . resolve ( __dirname , '../../lib ' ) ;
13- const content = analyzeDependencies ( componentName , libDir ) . map ( component => `require( '../../vant-css/${ component } .css') ;` ) ;
14- fs . outputFileSync ( path . join ( libDir , componentName , './style/index.js' ) , content . join ( '\n' ) ) ;
12+ const esDir = path . resolve ( __dirname , '../../es ' ) ;
13+ const content = analyzeDependencies ( componentName , esDir ) . map ( component => `import '../../vant-css/${ component } .css';` ) ;
14+ fs . outputFileSync ( path . join ( esDir , componentName , './style/index.js' ) , content . join ( '\n' ) ) ;
1515} ) ;
1616
1717// Analyze component dependencies
18- function analyzeDependencies ( componentName , libDir ) {
18+ function analyzeDependencies ( componentName , esDir ) {
1919 const checkList = [ 'base' ] ;
2020 const whiteList = [ 'icon' , 'loading' , 'cell' , 'button' ] ;
2121 search ( dependencyTree ( {
22- directory : libDir ,
23- filename : path . resolve ( libDir , componentName , 'index.js' ) ,
24- filter : path => path . indexOf ( `vant${ SEP } lib ${ SEP } ` ) !== - 1
22+ directory : esDir ,
23+ filename : path . resolve ( esDir , componentName , 'index.js' ) ,
24+ filter : path => path . indexOf ( `vant${ SEP } es ${ SEP } ` ) !== - 1
2525 } ) , checkList , whiteList ) ;
2626 return checkList . filter ( component => checkComponentHasStyle ( component ) ) ;
2727}
2828
2929function search ( tree , checkList , whiteList ) {
3030 tree && Object . keys ( tree ) . forEach ( key => {
3131 search ( tree [ key ] , checkList , whiteList ) ;
32- const component = key . split ( `${ SEP } vant${ SEP } lib ${ SEP } ` ) [ 1 ] . replace ( `${ SEP } index.js` , '' ) . replace ( `mixins${ SEP } ` , '' ) ;
32+ const component = key . split ( `${ SEP } vant${ SEP } es ${ SEP } ` ) [ 1 ] . replace ( `${ SEP } index.js` , '' ) . replace ( `mixins${ SEP } ` , '' ) ;
3333 if ( checkList . indexOf ( component ) === - 1 && whiteList . indexOf ( component ) === - 1 ) {
3434 checkList . push ( component ) ;
3535 }
3636 } ) ;
3737}
3838
3939function checkComponentHasStyle ( componentName ) {
40- return fs . existsSync ( path . join ( __dirname , '../../lib /vant-css/' , `${ componentName } .css` ) ) ;
40+ return fs . existsSync ( path . join ( __dirname , '../../es /vant-css/' , `${ componentName } .css` ) ) ;
4141}
0 commit comments