@@ -353,7 +353,7 @@ function imageSetMixin(decl, i) {
353
353
obj . path = "url(" + obj . url + ")" ;
354
354
obj . whichImg = paths [ j ] [ 3 ] ;
355
355
if ( obj . whichImg == "1x" || obj . whichImg == "1x" ) {
356
- var normalSizes = sizeOf ( _getResourceAbsolutePath ( obj . url ) ) ;
356
+ var normalSizes = sizeOf ( getAbsolutePath ( obj . url ) ) ;
357
357
normalWidth = normalSizes . width + 'px' ;
358
358
normalHeight = normalSizes . height + 'px' ;
359
359
@@ -362,7 +362,7 @@ function imageSetMixin(decl, i) {
362
362
value : obj . path
363
363
} ) ;
364
364
} else if ( obj . whichImg == "2x" || obj . whichImg == "2x" ) {
365
- var rSizes = sizeOf ( _getResourceAbsolutePath ( obj . url ) ) ; //2倍图尺寸
365
+ var rSizes = sizeOf ( getAbsolutePath ( obj . url ) ) ; //2倍图尺寸
366
366
rWidth = rSizes . width / 2 + 'px' ;
367
367
rHeight = rSizes . height / 2 + 'px' ;
368
368
bgSize = rWidth + ' ' + rHeight ; //2倍图的宽和高
@@ -405,7 +405,7 @@ function imageSetMixin(decl, i) {
405
405
} else if ( decl . value . indexOf ( 'url(' ) != - 1 ) {
406
406
//没有image-set,执行以下
407
407
var retinaPaths = returnURL ( decl . value , reNO_SETURL ) //获取第一个url图片的路径
408
- var retinaSizes = sizeOf ( _getResourceAbsolutePath ( retinaPaths [ 0 ] [ 2 ] ) ) ;
408
+ var retinaSizes = sizeOf ( getAbsolutePath ( retinaPaths [ 0 ] [ 2 ] ) ) ;
409
409
normalWidth = retinaSizes . width + 'px' ;
410
410
normalHeight = retinaSizes . height + 'px' ;
411
411
}
@@ -482,23 +482,23 @@ function returnURL(val, reg) {
482
482
}
483
483
484
484
//当前处理文件的路径,可以通过处理函数的opts.from得到
485
- var _currentProcessFilePath = '' ;
485
+ var currentFilePath = '' ;
486
486
//获取css文件中的资源的绝对地址
487
- function _getResourceAbsolutePath ( sourcePath ) {
488
- return path . resolve ( _currentProcessFilePath , sourcePath ) ;
487
+ function getAbsolutePath ( sourcePath ) {
488
+ return path . resolve ( currentFilePath , sourcePath ) ;
489
489
}
490
490
491
491
// PostCSS Processor
492
492
var cssprocess = function ( css , opts ) {
493
493
//保存当前处理文件路径
494
- _currentProcessFilePath = path . dirname ( opts . from ) ;
494
+ currentFilePath = path . dirname ( opts . from ) ;
495
495
css . eachRule ( cssgraceRule ) ;
496
496
}
497
497
498
498
var pack = function ( css , opts ) {
499
499
//保存当前处理文件路径
500
- _currentProcessFilePath = path . dirname ( opts . from ) ;
501
- console . log ( _currentProcessFilePath ) ;
500
+ currentFilePath = path . dirname ( opts . from ) ;
501
+ console . log ( currentFilePath ) ;
502
502
return postcss ( cssprocess ) . process ( css , opts ) . css ;
503
503
}
504
504
0 commit comments