nl_tokens: **************************************************************** 7 . 输出修改后的样式表 **************************************************************** 输出修改后的样式表
pl_tokens: function exportCssFile ( spriteTask ) { var cssContentList = [ ] , styleSheetArray = spriteTask . styleSheetArray , cssContent = '' , compressOptions = spriteConfig . output . compress , fileName , fileName2 , // 用于输出 log combinedCssRules , imageName , fileversion = spriteTask . fileversion ; if ( ! styleSheetArray ) { styleSheetArray = [ spriteTask . styleSheet ] } styleSheetArray . forEach ( function ( styleSheet ) { cssContentList . push ( styleSheetToString ( styleSheet ) ) ; } ) ; fileName = path . basename ( spriteTask . cssFileName ) ; fileName2 = path . join ( spriteConfig . output . cssDist , fileName ) ; fileName2 = path . normalize ( fileName2 ) ; fileName = path . join ( spriteConfig . workspace , fileName2 ) ; fileName = path . resolve ( fileName ) ; // 把合并了的样式统一在一起输出到文件的最后 if ( spriteConfig . output . combineCSSRule ) { combinedCssRules = spriteTask . combinedCssRules ; for ( imageName in combinedCssRules ) { var versionImageName = imageName ; if ( fileversion ) { versionImageName += '?' + fileversion ; } cssContent += combinedCssRules [ imageName ] . join ( ',' ) + '{' + 'background-image: url(' + versionImageName + ');' + '}\n' ; } } cssContent = cssContentList . join ( '\n' ) + cssContent ; if ( compressOptions ) { // 压缩 if ( ! us . isObject ( compressOptions ) ) { compressOptions = null ; } cssContent = new CleanCSS ( compressOptions ) . minify ( cssContent ) ; } nf . writeFileSync ( fileName , cssContent , <mask> ) ; info ( '>>Output css:' , fileName2 ) ; }