@@ -10,8 +10,13 @@ const write = function(pathLike, content) {
1010 fs . writeFileSync ( pathLike , content , 'utf-8' ) ;
1111} ;
1212
13+ const getImportLines = config => {
14+ const imports = config . import || [ ] ;
15+ return _ . map ( imports , path => `@import '${ path } ';` ) ;
16+ } ;
17+
1318const getModifyVariablesContent = variableConfig => {
14- const declaredContent = _ . map ( _ . entries ( variableConfig ) , ( [ key , value ] ) => `@${ key } :${ value } ;` ) ;
19+ const declaredContent = _ . map ( _ . entries ( variableConfig ) . filter ( ( [ key ] ) => key !== 'import' ) , ( [ key , value ] ) => `@${ key } :${ value } ;` ) ;
1520 return declaredContent . join ( '\r' ) ;
1621} ;
1722
@@ -27,8 +32,9 @@ const generateThemes = (themesConfig = {}, configs = {}) => {
2732 _ . forEach ( _ . entries ( themesConfig ) , ( [ theme , config ] ) => {
2833 const lessFileName = `${ theme } .less` ;
2934 const jsFileName = `${ theme } .js` ;
35+ const importLines = getImportLines ( config ) ;
3036 const modifyVariablesContent = getModifyVariablesContent ( config ) ;
31- const content = `${ typeof lessContent === 'function' ? lessContent ( theme , config ) : lessContent }
37+ const content = `${ typeof lessContent === 'function' ? lessContent ( theme , config ) : [ ... importLines , lessContent ] . join ( '\n' ) }
3238
3339${ preHeader }
3440${ modifyVariablesContent } `;
0 commit comments